public final class CountingInputStream extends InputStream
InputStream that counts the number of bytes that have
been read from the underlying stream. Bytes read multiple times are counted
as many times as they have been read. Skipped bytes are not counted.| Constructor and Description |
|---|
CountingInputStream(InputStream in)
Creates a new
CountingInputStream. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
long |
getCount()
Returns the number of bytes that have been read from the underlying
stream so far.
|
void |
mark(int readLimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
resetCount()
Sets the counter to 0 and returns its value before resetting it.
|
long |
skip(long n) |
public CountingInputStream(InputStream in)
CountingInputStream.in - the underlying stream.NullPointerException - if in is null.public long getCount()
public long resetCount()
public int available()
throws IOException
available in class InputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic void mark(int readLimit)
mark in class InputStreampublic boolean markSupported()
markSupported in class InputStreampublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic void reset()
throws IOException
reset in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionCopyright © 2012–2015. All rights reserved.