ccs.utils
Class MiserlyInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
ccs.utils.MiserlyInputStream
- All Implemented Interfaces:
- java.io.Closeable
public class MiserlyInputStream
- extends java.io.FilterInputStream
An inputstream which only provides data at a very limited rate. Useful for
testing, probably not useful in production code.
Fields inherited from class java.io.FilterInputStream |
in |
Constructor Summary |
MiserlyInputStream(java.io.InputStream in,
int dole)
Create a miserly input stream. |
Method Summary |
boolean |
markSupported()
|
int |
read(byte[] wad,
int off,
int len)
As its superclass, but provides at most dole bytes. |
long |
skip(long n)
As its superclass, but skips at most dole bytes. |
Methods inherited from class java.io.FilterInputStream |
available, close, mark, read, read, reset |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MiserlyInputStream
public MiserlyInputStream(java.io.InputStream in,
int dole)
- Create a miserly input stream.
- Parameters:
in
- The underlying stream.dole
- the maximum number of bytes provided by every read(byte[], int, int)
call.
markSupported
public boolean markSupported()
- Overrides:
markSupported
in class java.io.FilterInputStream
read
public int read(byte[] wad,
int off,
int len)
throws java.io.IOException
- As its superclass, but provides at most
dole
bytes.
- Overrides:
read
in class java.io.FilterInputStream
- Throws:
java.io.IOException
skip
public long skip(long n)
throws java.io.IOException
- As its superclass, but skips at most
dole
bytes.
- Overrides:
skip
in class java.io.FilterInputStream
- Throws:
java.io.IOException