public class StatsOutputStream extends OutputStream
Gather some statistics on the OutputStream
passed in the
constructor.
It can be used to read:
Full statistics are available after the stream has been fully processed (by other parts of the application), or after invoking the method close() while partial statistics are available on the fly.
Constructor and Description |
---|
StatsOutputStream(OutputStream destination)
Creates a new
SizeRecorderOutputStream with the given
destination stream. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
String |
getBitRateString()
Returns a string representation of the writing bit rate formatted with
a convenient unit.
|
long |
getSize()
Returns the number of bytes written until now.
|
long |
getTime(TimeUnit tu)
Returns the time spent waiting for the internal stream to write the
data.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public StatsOutputStream(OutputStream destination)
SizeRecorderOutputStream
with the given
destination stream.destination
- Destination stream where data are written.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
public String getBitRateString()
Returns a string representation of the writing bit rate formatted with a convenient unit. The unit will change trying to keep not more than 3 digits.
public long getSize()
public long getTime(TimeUnit tu)
Returns the time spent waiting for the internal stream to write the data.
tu
- Unit to measure the time.public void write(byte[] b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void write(int b) throws IOException
write
in class OutputStream
IOException
Copyright © 2008–2016. All rights reserved.