Class CountingOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.compress.utils.CountingOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Stream that tracks the number of bytes read.
- Since:
- 1.3
-
Field Summary
FieldsFields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class java.io.FilterOutputStream
close, flush
-
Field Details
-
bytesWritten
private long bytesWritten
-
-
Constructor Details
-
CountingOutputStream
-
-
Method Details
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
count
protected void count(long written) Increments the counter of already written bytes. Doesn't increment if the EOF has been hit (written == -1)- Parameters:
written
- the number of bytes written
-
getBytesWritten
public long getBytesWritten()Returns the current number of bytes written to this stream.- Returns:
- the number of written bytes
-