Top Description Fields Constructors Methods
com.google.common.io

public final Class CountingOutputStream

extends FilterOutputStream
Class Inheritance
Annotations
@J2ktIncompatible
@GwtIncompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull

An OutputStream that counts the number of bytes written.
Author
Chris Nokleberg
Since
1.0

Field Summary

Modifier and TypeField and Description
private long
Inherited from java.io.FilterOutputStream:
out

Constructor Summary

AccessConstructor and Description
public
CountingOutputStream(OutputStream
the output stream to be wrapped
out
)

Wraps another output stream, counting the number of bytes written.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with the stream.
public long
getCount()

Returns the number of bytes written.

public void
write(byte[]
the data.
b
,
int
the start offset in the data.
off
,
int
the number of bytes to write.
len
)

Overrides java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.
public void
write(int
the byte.
b
)

Overrides java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.
Inherited from java.io.FilterOutputStream:
flushwrite

Field Detail

countback to summary
private long count

Constructor Detail

CountingOutputStreamback to summary
public CountingOutputStream(OutputStream out)

Wraps another output stream, counting the number of bytes written.

Parameters
out:OutputStream

the output stream to be wrapped

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.FilterOutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.FilterOutputStream.close.

Closes this output stream and releases any system resources associated with the stream.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
getCountback to summary
public long getCount()

Returns the number of bytes written.

writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Parameters
b:byte[]

the data.

off:int

the start offset in the data.

len:int

the number of bytes to write.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(int b) throws IOException

Overrides java.io.FilterOutputStream.write.

Doc from java.io.FilterOutputStream.write.

Writes the specified byte to this output stream.

The write method of FilterOutputStream calls the write method of its underlying output stream, that is, it performs out.write(b).

Implements the abstract write method of OutputStream.

Parameters
b:int

the byte.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.