当前位置: 首页>>代码示例>>Java>>正文


Java BytesOf类代码示例

本文整理汇总了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
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:18,代码来源:TextOfTest.java

示例2: asString

import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Override
public String asString() throws IOException {
    return new TextOf(
        new Base64Bytes(
            new BytesOf(this.origin)
        )
    ).asString();
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:9,代码来源:Base64Text.java

示例3: asString

import org.cactoos.io.BytesOf; //导入依赖的package包/类
@Override
public String asString() throws IOException {
    return new TextOf(
        new BytesBase64(
            new BytesOf(this.origin)
        )
    ).asString();
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:9,代码来源:TextBase64.java

示例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()
        )
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:19,代码来源:Base64BytesTest.java

示例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()
        )
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:19,代码来源:BytesBase64Test.java

示例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("")
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:11,代码来源:HexOfTest.java

示例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")
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:11,代码来源:HexOfTest.java

示例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
            )
        )
    );
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:15,代码来源:TextOfTest.java

示例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);
}
 
开发者ID:yegor256,项目名称:wring,代码行数:30,代码来源:Cycle.java

示例10: TextAsBase64

import org.cactoos.io.BytesOf; //导入依赖的package包/类
/**
 * Ctor.
 * @param text Source text
 */
public TextAsBase64(final Text text) {
    this(new BytesOf(text));
}
 
开发者ID:smallcreep,项目名称:cedato-api-client,代码行数:8,代码来源:TextAsBase64.java

示例11: TextOf

import org.cactoos.io.BytesOf; //导入依赖的package包/类
/**
 * Ctor.
 *
 * @param input The Input
 */
public TextOf(final Input input) {
    this(new BytesOf(input));
}
 
开发者ID:yegor256,项目名称:cactoos,代码行数:9,代码来源:TextOf.java


注:本文中的org.cactoos.io.BytesOf类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。