當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。