Package org.terrier.utility.io
Class CountingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- org.terrier.utility.io.CountingInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class CountingInputStream extends java.io.FilterInputStreamSub-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
Fields Modifier and Type Field Description protected longcountnumber of bytes read or skipped
-
Constructor Summary
Constructors Constructor Description CountingInputStream(java.io.InputStream _in)Constructor - Calls Super ClassCountingInputStream(java.io.InputStream _in, long offset)Constructor - Calls Super Class
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetPos()Returns the Position in the Streamintread()Reads the Next Byte from the Streamintread(byte[] b, int off, int len)Reads the next Byte Array with Offset and Length from the Streamlongskip(long n)Calls Skip(long n)-
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset
-
-
-
-
Constructor Detail
-
CountingInputStream
public CountingInputStream(java.io.InputStream _in)
Constructor - Calls Super Class- Parameters:
_in- InputStream to wrap
-
CountingInputStream
public CountingInputStream(java.io.InputStream _in, long offset)Constructor - Calls Super Class- Parameters:
_in- InputStream to wrapoffset- Offset in bytes for which the counter should start
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionReads the Next Byte from the Stream- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionReads the next Byte Array with Offset and Length from the Stream- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOExceptionCalls Skip(long n)- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
getPos
public long getPos()
Returns the Position in the Stream- Returns:
- Position in bytes since the start of the stream
-
-