A typical use case would be during debugging, to ensure that data is being written as expected.
| Modifier and Type | Field and Description |
|---|---|
| private long | count
The count of bytes that have passed. |
| Access | Constructor and Description |
|---|---|
| public | CountingOutputStream(OutputStream
the OutputStream to write to out)Constructs a new CountingOutputStream. |
| 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 synchronized long | |
| public synchronized int | |
| public void | write(byte[]
the bytes to write, not null b)Overrides org. |
| public void | write(byte[]
the bytes to write, not null b, int the start offset in the buffer off, int the maximum number of bytes to write len)Overrides org. |
| public void | write(int
the byte to write b)Overrides org. |
| count | back to summary |
|---|---|
| private long count The count of bytes that have passed. | |
| CountingOutputStream | back to summary |
|---|---|
| public CountingOutputStream(OutputStream out) Constructs a new CountingOutputStream.
| |
| 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
| |
| 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
| |
| write | back to summary |
|---|---|
| public void write(byte[] b) throws IOException Overrides org. Writes the contents of the specified byte array to this output stream keeping count of the number of bytes written.
| |
| write | back to summary |
|---|---|
| public void write(byte[] b, int off, int len) throws IOException Overrides org. Writes a portion of the specified byte array to this output stream keeping count of the number of bytes written.
| |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Overrides org. Writes a single byte to the output stream adding to the count of the number of bytes written.
| |