ikrs.io
Class ReadLimitInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by ikrs.io.BytePositionInputStream
          extended by ikrs.io.ReadLimitInputStream
All Implemented Interfaces:
java.io.Closeable

public class ReadLimitInputStream
extends BytePositionInputStream

This input stream is an extension of the BytePositionInputStream. It stores a read limit (long) which, when reached, causes EOI.


Constructor Summary
ReadLimitInputStream(java.io.InputStream in, long readLimit)
           
 
Method Summary
 int available()
           
 void close()
           
protected  long getMaxAvailable()
           
 void mark(int readlimit)
          The mark-method is a bit tricky! This implementation does NOT support marks and throws an IOException if called.
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 java.lang.String toString()
           
 
Methods inherited from class ikrs.io.BytePositionInputStream
getAbsoluteBytePosition, getBytePosition, resetBytePosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReadLimitInputStream

public ReadLimitInputStream(java.io.InputStream in,
                            long readLimit)
                     throws java.lang.NullPointerException,
                            java.lang.IllegalArgumentException
Throws:
java.lang.NullPointerException
java.lang.IllegalArgumentException
Method Detail

getMaxAvailable

protected long getMaxAvailable()

available

public int available()
              throws java.io.IOException
Overrides:
available in class BytePositionInputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class BytePositionInputStream
Throws:
java.io.IOException

mark

public void mark(int readlimit)
The mark-method is a bit tricky! This implementation does NOT support marks and throws an IOException if called.

Overrides:
mark in class BytePositionInputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class BytePositionInputStream

read

public int read()
         throws java.io.IOException
Overrides:
read in class BytePositionInputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class BytePositionInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class BytePositionInputStream
Throws:
java.io.IOException

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class BytePositionInputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class BytePositionInputStream
Throws:
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class BytePositionInputStream