public class ByteCountingInputStream extends java.io.FilterInputStream
InputStream that keeps tracks of the number of consumed bytes
at any given time.| Modifier and Type | Field and Description |
|---|---|
protected long |
consumed
Offset relative to beginning of stream.
|
protected long |
counter
Byte counter which can also be changed.
|
static int |
READLINE_INITIAL_SIZE
Read line initial size.
|
| Constructor and Description |
|---|
ByteCountingInputStream(java.io.InputStream in)
Constructs an
InputStream that counts the bytes
as it reads them. |
| Modifier and Type | Method and Description |
|---|---|
long |
getConsumed()
Retrieve the number of bytes consumed by this stream.
|
long |
getCounter()
Retrieve the current counter value.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
void |
setCounter(long bytes)
Change the counter value.
|
long |
skip(long n) |
public static final int READLINE_INITIAL_SIZE
protected long consumed
protected long counter
public ByteCountingInputStream(java.io.InputStream in)
InputStream that counts the bytes
as it reads them.in - InputStream to wrappublic long getConsumed()
public void setCounter(long bytes)
bytes - new counter valuepublic long getCounter()
public boolean markSupported()
markSupported in class java.io.FilterInputStreampublic void mark(int readlimit)
mark in class java.io.FilterInputStreampublic void reset() throws java.io.IOException
reset in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read() throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic int read(byte[] b, int off, int len) throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionpublic long skip(long n) throws java.io.IOException
skip in class java.io.FilterInputStreamjava.io.IOExceptionCopyright © 2011–2023. All rights reserved.