Class RecordedInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class RecordedInputStream
    extends java.io.InputStream
    Wraps an InputStream and records all of the bytes read. This stream supports mark() and reset().

    Note: Buffered streams should wrap this class as opposed to the other way around.

    Author:
    J. H. S.
    • Constructor Summary

      Constructors 
      Constructor Description
      RecordedInputStream​(java.io.InputStream delegate, int maxBufferSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()  
      void close()  
      void consumeToEOF()  
      byte[] getBytesRead()  
      java.lang.String getString​(java.lang.String encoding)  
      boolean hasReachedEOF()  
      void mark​(int readlimit)  
      boolean markSupported()  
      int read()  
      int read​(byte[] buffer, int offset, int length)  
      void reset()  
      • Methods inherited from class java.io.InputStream

        nullInputStream, read, readAllBytes, readNBytes, readNBytes, skip, transferTo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RecordedInputStream

        public RecordedInputStream​(java.io.InputStream delegate,
                                   int maxBufferSize)
    • Method Detail

      • read

        public int read()
                 throws java.io.IOException
        Specified by:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • available

        public int available()
                      throws java.io.IOException
        Overrides:
        available in class java.io.InputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException
      • markSupported

        public boolean markSupported()
        Overrides:
        markSupported in class java.io.InputStream
      • mark

        public void mark​(int readlimit)
        Overrides:
        mark in class java.io.InputStream
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides:
        reset in class java.io.InputStream
        Throws:
        java.io.IOException
      • read

        public int read​(byte[] buffer,
                        int offset,
                        int length)
                 throws java.io.IOException
        Overrides:
        read in class java.io.InputStream
        Throws:
        java.io.IOException
      • consumeToEOF

        public void consumeToEOF()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • hasReachedEOF

        public boolean hasReachedEOF()