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
@GwtIncompatible public final class CountingOutputStream extends FilterOutputStream
An OutputStream that counts the number of bytes written.- Since:
- 1.0
- Author:
- Chris Nokleberg
-
-
Field Summary
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
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 void
close()
long
getCount()
Returns the number of bytes written.void
write(byte[] b, int off, int len)
void
write(int b)
-
Methods inherited from class java.io.FilterOutputStream
flush, write
-
Methods inherited from class java.io.OutputStream
nullOutputStream
-
-
-
-
Constructor Detail
-
CountingOutputStream
public CountingOutputStream(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:
write
in classFilterOutputStream
- Throws:
IOException
-
write
public void write(int b) throws IOException
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
-