|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
com.gc.iotools.stream.is.StatsInputStream
public class StatsInputStream
Gather some statistics of the InputStream 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.
Usage:
StatsInputStream srIstream = new StatsInputStream(originalStream); //performs all the application operation on stream performTasksOnStream(srIstream); srIstream.close(); long size = srIstream.getSize();
| Constructor Summary | |
|---|---|
StatsInputStream(InputStream source)
Constructs an SizeReaderInputStream. |
|
StatsInputStream(InputStream istream,
boolean fullReadOnClose)
Constructs an SizeReaderInputStream and allow to specify
actions to do on close. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
Closes the inner stream. |
float |
getRate()
Returns the reading bit rate in KB per second. |
long |
getSize()
Returns the bytes read until now or total length of the stream if the method has been called or EOF was reached. |
long |
getTime()
Returns the time in milliseconds spent until now waiting for the internal stream to respond. |
boolean |
isFullReadOnClose()
|
void |
mark(int readlimit)
|
boolean |
markSupported()
|
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
reset()
|
long |
skip(long n)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StatsInputStream(InputStream source)
Constructs an SizeReaderInputStream. When
close() is called all the data will be read from the source
InputStream and a full statistic will be available.
source - Stream whose statistics must be calculated.
public StatsInputStream(InputStream istream,
boolean fullReadOnClose)
SizeReaderInputStream and allow to specify
actions to do on close.
istream - Stream whose bytes must be counted.fullReadOnClose - if true after the close the inner stream is read
completely and the effective size of the inner stream is
calculated.| Method Detail |
|---|
public int available()
throws IOException
available in class InputStreamIOException
public void close()
throws IOException
fullReadOnClose was set in the
constructor it also count all the bytes of the underlying stream.
close in interface Closeableclose in class InputStreamIOException - if an I/O error occurs reading the whole content of the
stream.InputStream.close()public long getSize()
close() method has been called or EOF was reached.
public long getTime()
Returns the time in milliseconds spent until now waiting for the internal stream to respond.
public float getRate()
public boolean isFullReadOnClose()
public void mark(int readlimit)
mark in class InputStreampublic boolean markSupported()
markSupported in class InputStream
public int read()
throws IOException
read in class InputStreamIOException
public int read(byte[] b)
throws IOException
read in class InputStreamIOException
public int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOException
public void reset()
throws IOException
reset in class InputStreamIOException
public long skip(long n)
throws IOException
skip in class InputStreamIOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||