ikrs.io
Class BytePositionInputStream

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

public class BytePositionInputStream
extends java.io.InputStream


Constructor Summary
BytePositionInputStream(java.io.InputStream in)
           
 
Method Summary
 int available()
           
 void close()
           
 long getAbsoluteBytePosition()
          This method returns the absolute number of bytes that were already read.
 long getBytePosition()
          This method returns the number of bytes that were already read (unless the 'resetBytePosition()' method was called).
 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 resetBytePosition()
          This method resets the current byte position to 0.
 long skip(long n)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BytePositionInputStream

public BytePositionInputStream(java.io.InputStream in)
                        throws java.lang.NullPointerException
Throws:
java.lang.NullPointerException
Method Detail

getBytePosition

public long getBytePosition()
This method returns the number of bytes that were already read (unless the 'resetBytePosition()' method was called).

Returns:
The number of bytes that were already read.

resetBytePosition

public long resetBytePosition()
This method resets the current byte position to 0.


getAbsoluteBytePosition

public long getAbsoluteBytePosition()
This method returns the absolute number of bytes that were already read. The value is not affected by any 'resetBytePosition()' calls.

Returns:
The absolute (!) number of bytes that were already read.

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

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 java.io.InputStream

markSupported

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

read

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

read

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

read

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

reset

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

skip

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

toString

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