Return the new stream directly.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Mar 2013 21:29:37 +0000 (22:29 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 14 Mar 2013 21:29:37 +0000 (22:29 +0100)
src/main/java/net/pterodactylus/sonitus/io/RememberingInputStream.java

index ac2e5f0..5fae4b2 100644 (file)
@@ -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);
        }
 
        //