本文整理汇总了Java中org.cactoos.io.BytesOf类的典型用法代码示例。如果您正苦于以下问题:Java BytesOf类的具体用法?Java BytesOf怎么用?Java BytesOf使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BytesOf类属于org.cactoos.io包,在下文中一共展示了BytesOf类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readsFromReader
import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Test
public void readsFromReader() throws Exception {
final String source = "hello, друг!";
MatcherAssert.assertThat(
"Can't read string through a reader",
new TextOf(
new StringReader(source),
StandardCharsets.UTF_8
).asString(),
Matchers.equalTo(
new String(
new BytesOf(source).asBytes(),
StandardCharsets.UTF_8
)
)
);
}
示例2: asString
import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Override
public String asString() throws IOException {
return new TextOf(
new Base64Bytes(
new BytesOf(this.origin)
)
).asString();
}
示例3: asString
import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Override
public String asString() throws IOException {
return new TextOf(
new BytesBase64(
new BytesOf(this.origin)
)
).asString();
}
示例4: checkDecode
import org.cactoos.io.BytesOf; //导入依赖的package包/类
/**
* Check bytes decodes using the Base64 encoding scheme.
* @throws IOException If fails.
*/
@Test
public void checkDecode() throws IOException {
MatcherAssert.assertThat(
"Can't decodes bytes using the Base64 encoding scheme",
new Base64Bytes(
new BytesOf(
"SGVsbG8h"
)
).asBytes(),
Matchers.equalTo(
new BytesOf("Hello!").asBytes()
)
);
}
示例5: checkEncode
import org.cactoos.io.BytesOf; //导入依赖的package包/类
/**
* Check bytes encodes using the Base64 encoding scheme.
* @throws IOException If fails.
*/
@Test
public void checkEncode() throws IOException {
MatcherAssert.assertThat(
"Can't encodes bytes using the Base64 encoding scheme",
new BytesBase64(
new BytesOf(
"Hello!"
)
).asBytes(),
Matchers.equalTo(
new BytesOf("SGVsbG8h").asBytes()
)
);
}
示例6: empytString
import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Test
public void empytString() {
MatcherAssert.assertThat(
"Can't represent an empty string as hexadecimal",
new HexOf(
new BytesOf("")
),
new TextHasString("")
);
}
示例7: notEmpytString
import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Test
public void notEmpytString() throws IOException {
MatcherAssert.assertThat(
"Can't represent a string as hexadecimal",
new HexOf(
new BytesOf("What's up, друг?")
),
new TextHasString("5768617427732075702c20d0b4d180d183d0b33f")
);
}
示例8: readsFromReaderWithDefaultEncoding
import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Test
public void readsFromReaderWithDefaultEncoding() throws Exception {
final String source = "hello, друг! with default encoding";
MatcherAssert.assertThat(
"Can't read string with default encoding through a reader",
new TextOf(new StringReader(source)).asString(),
Matchers.equalTo(
new String(
new BytesOf(source).asBytes(),
StandardCharsets.UTF_8
)
)
);
}
示例9: exec
import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Override
public void exec(final Pipe pipe) throws Exception {
final XePrint print = new XePrint(pipe.asXembly());
final Events events = this.base.user(
print.text("{/pipe/urn/text()}")
).events();
final String json = print.text("{/pipe/json/text()}");
new UncheckedFunc<>(
new FuncWithFallback<>(
(Func<String, JsonObject>) str -> Json.createReader(
new ReaderOf(str)
).readObject(),
(Proc<Throwable>) error -> events.post(
Cycle.class.getCanonicalName(),
String.format(
"Failed to parse JSON:\n%s\n\n%s",
json, new TextOf(new BytesOf(error)).asString()
)
),
obj -> {
new Exec(
new JsonAgent(this.base, obj),
new IgnoreEvents(new BoostEvents(events, obj), obj),
pipe
).run();
}
)
).apply(json);
}
示例10: TextAsBase64
import org.cactoos.io.BytesOf; //导入依赖的package包/类
/**
* Ctor.
* @param text Source text
*/
public TextAsBase64(final Text text) {
this(new BytesOf(text));
}
示例11: TextOf
import org.cactoos.io.BytesOf; //导入依赖的package包/类
/**
* Ctor.
*
* @param input The Input
*/
public TextOf(final Input input) {
this(new BytesOf(input));
}