Package com.google.common.io
Class CountingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.google.common.io.CountingOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
@Beta public final class CountingOutputStream extends FilterOutputStream
An OutputStream that counts the number of bytes written.- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description CountingOutputStream(OutputStream out)Wraps another output stream, counting the number of bytes written.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetCount()Returns the number of bytes written.voidwrite(byte[] b, int off, int len)voidwrite(int b)-
Methods inherited from class java.io.FilterOutputStream
close, flush, write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
CountingOutputStream
public CountingOutputStream(@Nullable OutputStream out)
Wraps another output stream, counting the number of bytes written.- Parameters:
out- the output stream to be wrapped
-
-
Method Detail
-
getCount
public long getCount()
Returns the number of bytes written.
-
write
public void write(byte[] b, int off, int len) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
public void write(int b) throws IOException- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
-