A typical use case would be during debugging, to ensure that data is being read as expected.
| Modifier and Type | Field and Description |
|---|---|
| private long | count
The count of bytes that have passed. |
| Access | Constructor and Description |
|---|---|
| public | CountingInputStream(InputStream
the InputStream to delegate to in)Constructs a new CountingInputStream. |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized long | Returns: the number of bytes accumulatedThe number of bytes that have passed through this stream. |
| public synchronized int | Returns: the number of bytes accumulatedThe number of bytes that have passed through this stream. |
| public int | Returns: the total number of bytes read into the buffer, -1 if end of streamthe buffer into which the data is read, not null b)Overrides org. |
| public int | Returns: the total number of bytes read into the buffer, -1 if end of streamthe buffer into which the data is read, not null b, int the start offset in the buffer off, int the maximum number of bytes to read len)Overrides org. |
| public int | Returns: the byte read, -1 if end of streamOverrides org. |
| public synchronized long | |
| public synchronized int | |
| public long | Returns: the actual number of bytes skippedthe number of bytes to skip length)Overrides org. |
| count | back to summary |
|---|---|
| private long count The count of bytes that have passed. | |
| CountingInputStream | back to summary |
|---|---|
| public CountingInputStream(InputStream in) Constructs a new CountingInputStream.
| |
| getByteCount | back to summary |
|---|---|
| public synchronized long getByteCount() The number of bytes that have passed through this stream. Note This method is an alternative for
| |
| getCount | back to summary |
|---|---|
| public synchronized int getCount() The number of bytes that have passed through this stream. Note From v1.3 this method throws an ArithmeticException if the
count is greater than can be expressed by an
| |
| read | back to summary |
|---|---|
| public int read(byte[] b) throws IOException Overrides org. Reads a number of bytes into the byte array, keeping count of the number read.
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Overrides org. Reads a number of bytes into the byte array at a specific offset, keeping count of the number read.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Overrides org. Reads the next byte of data adding to the count of bytes received if a byte is successfully read.
| |
| resetByteCount | back to summary |
|---|---|
| public synchronized long resetByteCount() Set the byte count back to 0. Note This method is an alternative for
| |
| resetCount | back to summary |
|---|---|
| public synchronized int resetCount() Set the byte count back to 0. Note From v1.3 this method throws an ArithmeticException if the
count is greater than can be expressed by an
| |
| skip | back to summary |
|---|---|
| public long skip(final long length) throws IOException Overrides org. Skips the stream over the specified number of bytes, adding the skipped amount to the count.
| |