public final class CountingInputStream extends InputStream implements ConnectedTestable
Instances of this class are not safe for use by multiple threads.
| Constructor and Description |
|---|
CountingInputStream()
Create an empty counting input stream decorator.
|
CountingInputStream(InputStream stream)
Create a counting input stream decorator around a given input stream.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
long |
getCount()
Get the count of all imported bytes.
|
boolean |
isConnected()
Answer whether this object is currently connected.
|
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
removeStream()
Remove the input stream to be decorated.
|
void |
removeStream(boolean resetCounter)
Remove the input stream to be decorated.
|
void |
setCount(long count)
Set the count of all imported bytes to a given value.
|
void |
setStream(InputStream stream)
Set the input stream to be decorated or null if you want to remove the current stream.
|
void |
setStream(InputStream stream,
boolean resetCounter)
Set the input stream to be decorated or null if you want to remove the current stream.
|
long |
skip(long n) |
mark, markSupported, resetpublic CountingInputStream()
public CountingInputStream(InputStream stream)
stream - The input stream to be decoratedpublic final void setStream(InputStream stream)
An already existing stream will be removed before.
The counter will not be reset.
stream - The input stream to be decoratedpublic final void setStream(InputStream stream, boolean resetCounter)
An already existing stream will be removed before.
stream - The input stream to be decoratedresetCounter - Flag whether the counter has to be reset to zeropublic final void removeStream()
The counter will not be reset.
public final void removeStream(boolean resetCounter)
resetCounter - Flag whether the counter has to be reset to zeropublic final long getCount()
public final void setCount(long count)
count - The count to be setpublic final int read()
read in class InputStreampublic final int read(byte[] b)
read in class InputStreampublic final int read(byte[] b,
int off,
int len)
read in class InputStreampublic final long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic final int available()
available in class InputStreampublic final boolean isConnected()
ConnectedTestableisConnected in interface ConnectedTestablepublic final void close()
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamCopyright © 2019. All rights reserved.