|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream net.sf.basedb.util.InputStreamTracker
public class InputStreamTracker
This class is used to keep track of the number of bytes read from the underlying input stream. This is very useful for code that needs to reporter progress but are having difficulties to know the number of processed bytes.
Field Summary | |
---|---|
private InputStream |
in
The source input stream to read from. |
private long |
numRead
The number of bytes that has been read from the underlying input stream so far. |
private long |
numReadAtMark
The number of bytes that had been read when mark(int)
was called. |
Constructor Summary | |
---|---|
InputStreamTracker(InputStream in)
Create a new input stream tracker. |
Method Summary | |
---|---|
int |
available()
|
void |
close()
|
long |
getNumRead()
Get the number of bytes read or skipped from the input stream. |
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 |
Field Detail |
---|
private final InputStream in
private long numRead
private long numReadAtMark
mark(int)
was called.
Constructor Detail |
---|
public InputStreamTracker(InputStream in)
in
- The input stream to read fromMethod Detail |
---|
public int available() throws IOException
available
in class InputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in class InputStream
IOException
public void mark(int readlimit)
mark
in class InputStream
public boolean markSupported()
markSupported
in class InputStream
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read
in class InputStream
IOException
public void reset() throws IOException
reset
in class InputStream
IOException
public long skip(long n) throws IOException
skip
in class InputStream
IOException
public long getNumRead()
reset()
this will also
reset the number of read bytes to the latest mark(int)
position.
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |