|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
ccs.utils.DammedInputStream
public class DammedInputStream
An input stream which only allows access to a fixed length of the
underlying stream. After this limit (the "dam") has been reached,
further read attempts return EOF and the underyling stream is not
read. Note that this is not the exact mirror-image of
DammedOutputStream
.
Field Summary |
---|
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
DammedInputStream(java.io.InputStream in,
long quota)
Creates an input stream with a fixed number of bytes available before the "dam". |
Method Summary | |
---|---|
int |
available()
returns the maximum number of bytes that can be read without blocking. |
void |
mark(int readlimit)
Sets a mark for mark/reset operations. |
boolean |
markSupported()
indicates whether mark/reset operations are supported, which they are not. |
int |
read()
reads a single byte from the underlying stream. |
int |
read(byte[] b,
int off,
int len)
reads up to len bytes into b starting
at position off . |
long |
remaining()
The number of bytes remaining until the dam is reached, or -1 if no dam is active. |
void |
reset()
repostitions the stream over a previously set mark. |
void |
setDam(long quota)
Sets the dam to a new quota, relative to the current position |
long |
skip(long n)
skips at most n bytes of the underlying stream. |
Methods inherited from class java.io.FilterInputStream |
---|
close, read |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DammedInputStream(java.io.InputStream in, long quota)
in
- the underlying input streamquota
- the number of bytes which may be taken from in
.
If -1, the dam is disabled.Method Detail |
---|
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
- if an I/O error occurs.public int read(byte[] b, int off, int len) throws java.io.IOException
len
bytes into b
starting
at position off
.
read
in class java.io.FilterInputStream
b
- the array to read into.off
- the offset to start from.len
- the maximum length to read.
java.io.IOException
- if an I/O error occurs.public long skip(long n) throws java.io.IOException
skip
in class java.io.FilterInputStream
n
- the maximum number of bytes to skip.
java.io.IOException
- if an I/O error occurs.public int available() throws java.io.IOException
available
in class java.io.FilterInputStream
java.io.IOException
- if an I/O error occurs.public long remaining()
public void mark(int readlimit)
mark
in class java.io.FilterInputStream
readlimit
- the length readable before the mark becomes invalid (if
it were valid at all).public void reset() throws java.io.IOException
reset
in class java.io.FilterInputStream
java.io.IOException
- if called.public boolean markSupported()
markSupported
in class java.io.FilterInputStream
public void setDam(long quota)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |