org.terrier.utility.io
Class CountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by org.terrier.utility.io.CountingInputStream
All Implemented Interfaces:
Closeable

public class CountingInputStream
extends FilterInputStream

Sub-Class of Filter Input Stream with the extra method getPos which returns the position in the Stream

Author:
Richard McCreadie and Craig Macdonald

Field Summary
protected  long count
          number of bytes read or skipped
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
CountingInputStream(InputStream _in)
          Constructor - Calls Super Class
CountingInputStream(InputStream _in, long offset)
          Constructor - Calls Super Class
 
Method Summary
 long getPos()
          Returns the Position in the Stream
 int read()
          Reads the Next Byte from the Stream
 int read(byte[] b, int off, int len)
          Reads the next Byte Array with Offset and Length from the Stream
 long skip(long n)
          Calls Skip(long n)
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

protected long count
number of bytes read or skipped

Constructor Detail

CountingInputStream

public CountingInputStream(InputStream _in)
Constructor - Calls Super Class

Parameters:
_in - InputStream to wrap

CountingInputStream

public CountingInputStream(InputStream _in,
                           long offset)
Constructor - Calls Super Class

Parameters:
_in - InputStream to wrap
offset - Offset in bytes for which the counter should start
Method Detail

read

public int read()
         throws IOException
Reads the Next Byte from the Stream

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Reads the next Byte Array with Offset and Length from the Stream

Overrides:
read in class FilterInputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Calls Skip(long n)

Overrides:
skip in class FilterInputStream
Throws:
IOException

getPos

public long getPos()
Returns the Position in the Stream

Returns:
Position in bytes since the start of the stream


Terrier 3.6. Copyright © 2004-2011 University of Glasgow