public class StatsWriter extends Writer
A delegating Writer that gather statistics on the
Writer 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 |
|---|
StatsWriter(Writer destination)
Creates a new
StatsWriter with the given destination
character 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 characters written until now.
|
long |
getTime(TimeUnit tu)
Returns the time spent waiting for the internal stream to write the data.
|
void |
write(char[] b) |
void |
write(char[] b,
int off,
int len) |
void |
write(int b) |
public StatsWriter(Writer destination)
StatsWriter with the given destination
character stream.destination - Destination stream where data are written.public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class WriterIOExceptionpublic 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(char[] b)
throws IOException
write in class WriterIOExceptionpublic void write(char[] b,
int off,
int len)
throws IOException
write in class WriterIOExceptionpublic void write(int b)
throws IOException
write in class WriterIOExceptionCopyright © 2008–2016. All rights reserved.