From 3850f5b12de9bb6c1a3cef2f0082454e06645b5d Mon Sep 17 00:00:00 2001 From: yegor256 Date: Thu, 22 Jun 2017 08:10:44 +0300 Subject: [PATCH] extra ctors --- README.md | 2 +- .../java/org/cactoos/text/BytesAsText.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7365e97c81..3aa8975b70 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ To sort a list of words in the file: ```java List sorted = new SortedList<>( new IterableAsList<>( - new TextAsLines( + new SplitText( new BytesAsText( new InputAsBytes( new FileAsInput( diff --git a/src/main/java/org/cactoos/text/BytesAsText.java b/src/main/java/org/cactoos/text/BytesAsText.java index b76b49947a..481305da41 100644 --- a/src/main/java/org/cactoos/text/BytesAsText.java +++ b/src/main/java/org/cactoos/text/BytesAsText.java @@ -27,7 +27,9 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import org.cactoos.Bytes; +import org.cactoos.Input; import org.cactoos.Text; +import org.cactoos.io.InputAsBytes; /** * Bytes as Text. @@ -53,6 +55,15 @@ public final class BytesAsText implements Text { */ private final Charset charset; + /** + * Ctor. + * @param input Bytes from the input + * @since 0.8 + */ + public BytesAsText(final Input input) { + this(new InputAsBytes(input)); + } + /** * Ctor. * @param bts Bytes to encapsulate @@ -69,6 +80,16 @@ public BytesAsText(final Bytes bts) { this(bts, StandardCharsets.UTF_8); } + /** + * Ctor. + * @param input Input + * @param cset Charset + * @since 0.8 + */ + public BytesAsText(final Input input, final Charset cset) { + this(new InputAsBytes(input), cset); + } + /** * Ctor. * @param bts Bytes to encapsulate