org.esau.ptarmigan.util
Class CountingInputStream
java.lang.Object
|
+--java.io.InputStream
|
+--java.io.FilterInputStream
|
+--org.esau.ptarmigan.util.CountingInputStream
- public class CountingInputStream
- extends java.io.FilterInputStream
Counts the number of bytes that pass through it.
Note that the counter in this filter is independent of the
mark/reset logic. If you wish to reset the counter when you
reset the mark, you'll have to do so manually with a call
to resetCount().
Note that this class has its own renamed read() methods. This
is to insulate a buffered parent class that will read-ahead as
necessary.
- Version:
- $Revision: 1.3 $ $Date: 2002/10/02 05:30:04 $
- Author:
- Reed Esau
Fields inherited from class java.io.FilterInputStream |
in |
Method Summary |
int |
fastForward(int n)
a substitute for skip, which doesn't seem to want to work
correctly on buffered streams
|
long |
getCount()
The number of bytes that have passed through this stream. |
long |
getLimit()
|
long |
getRemaining()
|
int |
readC()
|
int |
readC(byte[] b)
|
int |
readC(byte[] b,
int off,
int len)
|
void |
resetCount()
Start the count at zero |
boolean |
rewind(int n)
reposition the stream from the last mark point (in case we
read too far)
|
void |
setLimit(long limit)
|
long |
skipC(long n)
|
Methods inherited from class java.io.FilterInputStream |
available, close, mark, markSupported, read, read, read, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CountingInputStream
public CountingInputStream(java.io.InputStream in)
CountingInputStream
public CountingInputStream(java.io.InputStream in,
long limit)
readC
public int readC()
throws java.io.IOException
readC
public int readC(byte[] b)
throws java.io.IOException
readC
public int readC(byte[] b,
int off,
int len)
throws java.io.IOException
skipC
public long skipC(long n)
throws java.io.IOException
getCount
public long getCount()
- The number of bytes that have passed through this stream.
resetCount
public void resetCount()
- Start the count at zero
getLimit
public long getLimit()
setLimit
public void setLimit(long limit)
getRemaining
public long getRemaining()
fastForward
public int fastForward(int n)
throws java.io.IOException
- a substitute for skip, which doesn't seem to want to work
correctly on buffered streams
TODO: should be 'long' param?
rewind
public boolean rewind(int n)
throws java.io.IOException
- reposition the stream from the last mark point (in case we
read too far)
TODO: should be 'long' param?
- Returns:
- true if rewind was successful; false if we had read beyond the limit of the mark
Copyright © 2002 Reed Esau, All Rights Reserved.