java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
i2p.susi.util.CountingOutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
OutputStream that counts bytes written.
Field Summary
FieldsFields inherited from class FilterOutputStream
outConstructor Summary
ConstructorsConstructorDescriptionCreate a CountingOutputStream wrapping the given output stream.Method Summary
All MethodsMethods inherited from class FilterOutputStream
close, flush, writeMethods inherited from class OutputStream
nullOutputStream
Field Details
count
private long countBytes written so far.
Constructor Details
CountingOutputStream
Create a CountingOutputStream wrapping the given output stream.- Parameters:
out- the underlying output stream
Method Details
getWritten
public long getWritten()Get the total number of bytes written so far.- Returns:
- total bytes written
write
Write a single byte and count it.- Overrides:
writein classFilterOutputStream- Parameters:
val- the byte to write- Throws:
IOException- on I/O error
write
Write bytes from a buffer and count them.- Overrides:
writein classFilterOutputStream- Parameters:
src- the buffer to write fromoff- the start offset in the bufferlen- the number of bytes to write- Throws:
IOException- on I/O error