public class ConfinedInputStream
extends java.io.FilterInputStream
InputStream
wrapper that limits the number of bytes that can be read form the underlying InputStream
.Modifier | Constructor and Description |
---|---|
protected |
ConfinedInputStream(java.io.InputStream in) |
protected |
ConfinedInputStream(java.io.InputStream in,
int lim) |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the number of bytes not yet consumed.
|
void |
close()
Closes this stream and throws away any bytes not consumed from the underlying
InputStream . |
protected long |
dumpLeftovers()
Skips the number bytes not yet consumed from the underlying
InputStream . |
int |
read() |
int |
read(byte[] b)
Forwards the read to
read(byte[], int, int) . |
int |
read(byte[] b,
int off,
int len)
Reads bytes from the underlying
InputStream up to the number of bytes defined in this ConfinedInputStream limit. |
int |
resetLimit(int len)
Resets this
ConfinedInputStream limit so that it can be reused over the same underlying InputStream . |
protected ConfinedInputStream(java.io.InputStream in)
protected ConfinedInputStream(java.io.InputStream in, int lim)
public int available() throws java.io.IOException
InputStream
available
in class java.io.FilterInputStream
java.io.IOException
FilterInputStream.available()
public void close() throws java.io.IOException
InputStream
.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterInputStream
java.io.IOException
FilterInputStream.close()
public int read() throws java.io.IOException
read
in class java.io.FilterInputStream
java.io.IOException
FilterInputStream.read()
public int read(byte[] b) throws java.io.IOException
read(byte[], int, int)
.read
in class java.io.FilterInputStream
java.io.IOException
FilterInputStream.read(byte[])
public int read(byte[] b, int off, int len) throws java.io.IOException
InputStream
up to the number of bytes defined in this ConfinedInputStream
limit.read
in class java.io.FilterInputStream
java.io.IOException
FilterInputStream.read(byte[], int, int)
public int resetLimit(int len)
ConfinedInputStream
limit so that it can be reused over the same underlying InputStream
.len
- the new length to set.protected long dumpLeftovers() throws java.io.IOException
InputStream
.java.io.IOException
- if any of the underlying I/O operations fail.