diff --git a/src/main/java/org/cactoos/io/BytesAsInput.java b/src/main/java/org/cactoos/io/BytesAsInput.java index 15f7dad450..0b13b0f5c5 100644 --- a/src/main/java/org/cactoos/io/BytesAsInput.java +++ b/src/main/java/org/cactoos/io/BytesAsInput.java @@ -28,6 +28,7 @@ import java.io.InputStream; import org.cactoos.Bytes; import org.cactoos.Input; +import org.cactoos.text.ArrayAsBytes; import org.cactoos.text.TextAsBytes; /** @@ -55,6 +56,14 @@ public BytesAsInput(final String text) { this(new TextAsBytes(text)); } + /** + * Ctor. + * @param bytes The bytes + */ + public BytesAsInput(final byte[] bytes) { + this(new ArrayAsBytes(bytes)); + } + /** * Ctor. * @param bytes The bytes diff --git a/src/main/java/org/cactoos/io/TeeInput.java b/src/main/java/org/cactoos/io/TeeInput.java index 246c6d81f2..b21e2dd181 100644 --- a/src/main/java/org/cactoos/io/TeeInput.java +++ b/src/main/java/org/cactoos/io/TeeInput.java @@ -23,8 +23,10 @@ */ package org.cactoos.io; +import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Path; import org.cactoos.Input; import org.cactoos.Output; @@ -49,6 +51,86 @@ public final class TeeInput implements Input { */ private final Output target; + /** + * Ctor. + * @param input The source + * @param output The output file + * @since 0.5 + */ + public TeeInput(final Path input, final Path output) { + this(new PathAsInput(input), new PathAsOutput(output)); + } + + /** + * Ctor. + * @param input The source + * @param output The output file + * @since 0.5 + */ + public TeeInput(final Path input, final File output) { + this(new PathAsInput(input), new FileAsOutput(output)); + } + + /** + * Ctor. + * @param input The source + * @param output The output file + * @since 0.5 + */ + public TeeInput(final File input, final File output) { + this(new FileAsInput(input), new FileAsOutput(output)); + } + + /** + * Ctor. + * @param input The source + * @param output The output file + * @since 0.5 + */ + public TeeInput(final File input, final Path output) { + this(new FileAsInput(input), new PathAsOutput(output)); + } + + /** + * Ctor. + * @param input The source + * @param file The output file + * @since 0.5 + */ + public TeeInput(final String input, final File file) { + this(new BytesAsInput(input), new FileAsOutput(file)); + } + + /** + * Ctor. + * @param input The source + * @param file The output file + * @since 0.5 + */ + public TeeInput(final String input, final Path file) { + this(new BytesAsInput(input), new PathAsOutput(file)); + } + + /** + * Ctor. + * @param input The source + * @param file The output file + * @since 0.5 + */ + public TeeInput(final byte[] input, final Path file) { + this(new BytesAsInput(input), new PathAsOutput(file)); + } + + /** + * Ctor. + * @param input The source + * @param output The target + * @since 0.5 + */ + public TeeInput(final String input, final Output output) { + this(new BytesAsInput(input), output); + } + /** * Ctor. * @param input The source diff --git a/src/test/java/org/cactoos/io/TeeInputTest.java b/src/test/java/org/cactoos/io/TeeInputTest.java index ca14a5550c..93914a8e30 100644 --- a/src/test/java/org/cactoos/io/TeeInputTest.java +++ b/src/test/java/org/cactoos/io/TeeInputTest.java @@ -31,7 +31,6 @@ import org.cactoos.TextHasString; import org.cactoos.func.FuncAsMatcher; import org.cactoos.text.BytesAsText; -import org.cactoos.text.StringAsText; import org.cactoos.text.TextAsBytes; import org.hamcrest.MatcherAssert; import org.junit.Test; @@ -79,14 +78,7 @@ public void copiesToFile() throws IOException { "Can't copy Input to File and return content", new BytesAsText( new InputAsBytes( - new TeeInput( - new BytesAsInput( - new TextAsBytes( - new StringAsText("Hello, друг!") - ) - ), - new PathAsOutput(temp) - ) + new TeeInput("Hello, друг!", temp) ) ), new TextHasString(