InputStream that counts the number of bytes read.
| Modifier and Type | Field and Description |
|---|---|
| private long | |
| private long |
| Access | Constructor and Description |
|---|---|
| public | CountingInputStream(InputStream
the input stream to be wrapped in)Wraps another input stream, counting the number of bytes read. |
| Modifier and Type | Method and Description |
|---|---|
| public long | |
| public synchronized void | mark(int
the maximum limit of bytes that can be read before
the mark position becomes invalid. readlimit)Overrides java. |
| public int | |
| public int | read(byte[]
the buffer into which the data is read. b, int the start offset in array off, int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. len bytes of data from this input stream
into an array of bytes.
|
| public synchronized void | reset()
Overrides java. mark method was last called on this input stream.
|
| public long | skip(long
the number of bytes to be skipped. n)Overrides java. n bytes of data from the
input stream.
|
| CountingInputStream | back to summary |
|---|---|
| public CountingInputStream(InputStream in) Wraps another input stream, counting the number of bytes read.
| |
| getCount | back to summary |
|---|---|
| public long getCount() Returns the number of bytes read. | |
| mark | back to summary |
|---|---|
| public synchronized void mark(int readlimit) Overrides java. Doc from java. Marks the current position in this input stream. A subsequent
call to the
The
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Overrides java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Overrides java. Doc from java. Reads up to
| |
| reset | back to summary |
|---|---|
| public synchronized void reset() throws IOException Overrides java. Doc from java. Repositions this stream to the position at the time the
Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.
| |
| skip | back to summary |
|---|---|
| public long skip(long n) throws IOException Overrides java. Doc from java. Skips over and discards
| |