Package com.google.common.io
Class CountingOutputStream
-
-
-
- com.google.common.io.CountingOutputStream
-
-
-
- All Implemented Interfaces:
,
,
@GwtIncompatible public final class CountingOutputStream extends
An OutputStream that counts the number of bytes written.- Since:
- 1.0
- Author:
- Chris Nokleberg
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this output stream and releases any system resources associated with the stream.long
getCount()
Returns the number of bytes written.void
write(byte[] b, int off, int len)
Writeslen
bytes from the specifiedbyte
array starting at offsetoff
to this output stream.void
write(int b)
Writes the specifiedbyte
to this output stream.
-
-
-
Method Detail
-
getCount
public long getCount()
Returns the number of bytes written.
-
write
public void write(byte[] b, int off, int len) throws
Description copied from class:Writeslen
bytes from the specifiedbyte
array starting at offsetoff
to this output stream.The
write
method ofFilterOutputStream
calls thewrite
method of one argument on eachbyte
to output.Note that this method does not call the
write
method of its underlying output stream with the same arguments. Subclasses ofFilterOutputStream
should provide a more efficient implementation of this method.- Overrides:
in class
- Parameters:
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.- Throws:
- if an I/O error occurs.
- See Also:
-
write
public void write(int b) throws
Description copied from class:Writes the specifiedbyte
to this output stream.The
write
method ofFilterOutputStream
calls thewrite
method of its underlying output stream, that is, it performsout.write(b)
.Implements the abstract
write
method ofOutputStream
.- Overrides:
in class
- Parameters:
b
- thebyte
.- Throws:
- if an I/O error occurs.
-
close
public void close() throws
Description copied from class:Closes this output stream and releases any system resources associated with the stream.When not already closed, the
close
method ofFilterOutputStream
calls itsflush
method, and then calls theclose
method of its underlying output stream.- Specified by:
in interface
- Specified by:
in interface
- Overrides:
in class
- Throws:
- if an I/O error occurs.
- See Also:
- ,
-
-