diff --git a/src/main/java/org/cactoos/io/ReaderOf.java b/src/main/java/org/cactoos/io/ReaderOf.java index 73d1091364..fd27bb50f8 100644 --- a/src/main/java/org/cactoos/io/ReaderOf.java +++ b/src/main/java/org/cactoos/io/ReaderOf.java @@ -27,7 +27,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStream; import java.io.Reader; import java.io.UnsupportedEncodingException; import java.net.URI; @@ -39,6 +38,7 @@ import java.nio.file.Path; import org.cactoos.Bytes; import org.cactoos.Input; +import org.cactoos.Output; import org.cactoos.Scalar; import org.cactoos.Text; import org.cactoos.scalar.StickyScalar; @@ -280,13 +280,13 @@ public ReaderOf(final InputStream stream, final CharsetDecoder decoder) { /** * Ctor. - * @param input The input stream - * @param out The output stream + * @param input The input + * @param out The output */ - public ReaderOf(final InputStream input, final OutputStream out) { + public ReaderOf(final Input input, final Output out) { this( new TeeReader( - input, + input, StandardCharsets.UTF_8, out, StandardCharsets.UTF_8 @@ -297,26 +297,26 @@ public ReaderOf(final InputStream input, final OutputStream out) { // @checkstyle ParameterNumberCheck (8 line) /** * Ctor. - * @param input The input stream + * @param input The input * @param dec The input decoder - * @param out The output stream + * @param out The output * @param enc The output encoder */ - public ReaderOf(final InputStream input, final CharsetDecoder dec, - final OutputStream out, final CharsetEncoder enc) { + public ReaderOf(final Input input, final CharsetDecoder dec, + final Output out, final CharsetEncoder enc) { this(new TeeReader(input, dec.charset(), out, enc.charset())); } // @checkstyle ParameterNumberCheck (8 line) /** * Ctor. - * @param input The input stream + * @param input The input * @param inchar The input charset - * @param out The output stream + * @param out The output * @param outchar The output charset */ - public ReaderOf(final InputStream input, final Charset inchar, - final OutputStream out, final Charset outchar) { + public ReaderOf(final Input input, final Charset inchar, + final Output out, final Charset outchar) { this( new TeeReader( input, @@ -330,13 +330,13 @@ public ReaderOf(final InputStream input, final Charset inchar, // @checkstyle ParameterNumberCheck (8 line) /** * Ctor. - * @param input The input stream + * @param input The input * @param inchar The input charset - * @param out The output stream + * @param out The output * @param outchar The output charset */ - public ReaderOf(final InputStream input, final String inchar, - final OutputStream out, final String outchar) { + public ReaderOf(final Input input, final String inchar, + final Output out, final String outchar) { this( new TeeReader( input, diff --git a/src/main/java/org/cactoos/io/TeeReader.java b/src/main/java/org/cactoos/io/TeeReader.java index 29c2f99dbe..40c0c66d4e 100644 --- a/src/main/java/org/cactoos/io/TeeReader.java +++ b/src/main/java/org/cactoos/io/TeeReader.java @@ -24,12 +24,11 @@ package org.cactoos.io; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; import java.io.Reader; +import java.io.Writer; import java.nio.charset.Charset; +import org.cactoos.Input; +import org.cactoos.Output; /** * Input to Output copying reader. @@ -44,12 +43,12 @@ public final class TeeReader extends Reader { /** * The source. */ - private final InputStreamReader reader; + private final Reader reader; /** * The destination. */ - private final OutputStreamWriter writer; + private final Writer writer; // @checkstyle ParameterNumberCheck (8 line) /** @@ -59,11 +58,11 @@ public final class TeeReader extends Reader { * @param out The destination * @param outcharset The destination charset */ - TeeReader(final InputStream input, final Charset incharset, - final OutputStream out, final Charset outcharset) { + TeeReader(final Input input, final Charset incharset, + final Output out, final Charset outcharset) { super(); - this.reader = new InputStreamReader(input, incharset); - this.writer = new OutputStreamWriter(out, outcharset); + this.reader = new ReaderOf(input, incharset); + this.writer = new WriterTo(out, outcharset); } @Override diff --git a/src/test/java/org/cactoos/io/TeeReaderTest.java b/src/test/java/org/cactoos/io/TeeReaderTest.java index 6df3934165..381497b39b 100644 --- a/src/test/java/org/cactoos/io/TeeReaderTest.java +++ b/src/test/java/org/cactoos/io/TeeReaderTest.java @@ -23,8 +23,6 @@ */ package org.cactoos.io; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.Reader; import java.nio.charset.StandardCharsets; @@ -51,8 +49,8 @@ public void testTeeReader() throws IOException { final String content = "Hello, товарищ!"; Files.write(src, content.getBytes(StandardCharsets.UTF_8)); final Reader reader = new ReaderOf( - new FileInputStream(src.toFile()), - new FileOutputStream(dst.toFile()) + new InputOf(src), + new OutputTo(dst) ); int done = 0; while (done >= 0) {