org.lobobrowser.util.io
Class RecordedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.lobobrowser.util.io.RecordedInputStream
All Implemented Interfaces:
java.io.Closeable

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
RecordedInputStream(java.io.InputStream delegate, int maxBufferSize)
           
 
Method Summary
 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
read, skip
 
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.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

getBytesRead

public byte[] getBytesRead()
                    throws BufferExceededException
Throws:
BufferExceededException

getString

public java.lang.String getString(java.lang.String encoding)
                           throws java.io.UnsupportedEncodingException,
                                  BufferExceededException
Throws:
java.io.UnsupportedEncodingException
BufferExceededException

hasReachedEOF

public boolean hasReachedEOF()