public class CountingInputStream extends FilterInputStream implements ReadCounter
| Modifier and Type | Field and Description |
|---|---|
protected long | counttotal bytes read or skipped |
in| Constructor and Description |
|---|
CountingInputStream(InputStream in)Create a CountingInputStream wrapping the given input stream. |
| Modifier and Type | Method and Description |
|---|---|
long | getRead()Get the total number of bytes read or skipped so far. |
int | read()Read a single byte and count it. |
int | read(byte[] buf,
int off,
int len)Read bytes into a buffer and count them. |
long | skip(long n)Skip bytes and count them. |
available, close, mark, markSupported, read, resetpublic CountingInputStream(InputStream in)
in - the underlying input streampublic long getRead()
getRead in interface ReadCounterpublic int read()
throws IOExceptionread in class FilterInputStreamIOException - on I/O errorpublic int read(byte[] buf,
int off,
int len)
throws IOExceptionread in class FilterInputStreambuf - the buffer to read intooff - the start offset in the bufferlen - the maximum number of bytes to readIOException - on I/O errorpublic long skip(long n)
throws IOExceptionskip in class FilterInputStreamn - number of bytes to skipIOException - on I/O error