From 0c170835a9bc25d24c01f119d87fe3644052381f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 14 Mar 2013 22:29:37 +0100 Subject: [PATCH] Return the new stream directly. --- .../java/net/pterodactylus/sonitus/io/RememberingInputStream.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/sonitus/io/RememberingInputStream.java b/src/main/java/net/pterodactylus/sonitus/io/RememberingInputStream.java index ac2e5f0..5fae4b2 100644 --- a/src/main/java/net/pterodactylus/sonitus/io/RememberingInputStream.java +++ b/src/main/java/net/pterodactylus/sonitus/io/RememberingInputStream.java @@ -22,6 +22,7 @@ import java.io.ByteArrayOutputStream; import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.SequenceInputStream; /** * Wrapper around an {@link InputStream} that remembers all bytes that have been @@ -51,12 +52,13 @@ public class RememberingInputStream extends FilterInputStream { // /** - * Returns all remembered bytes as an {@link InputStream}. + * Returns an input stream that repeats the originally wrapped stream, + * including all bytes that have already been read. * - * @return All remembered bytes + * @return A new input stream with the original content */ public InputStream remembered() { - return new ByteArrayInputStream(rememberBuffer.toByteArray()); + return new SequenceInputStream(new ByteArrayInputStream(rememberBuffer.toByteArray()), in); } // -- 2.7.4