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
InputStreamavailable in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.available()public void close()
throws java.io.IOException
InputStream.close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.close()public int read()
throws java.io.IOException
read in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.read()public int read(byte[] b)
throws java.io.IOException
read(byte[], int, int).read in class java.io.FilterInputStreamjava.io.IOExceptionFilterInputStream.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.FilterInputStreamjava.io.IOExceptionFilterInputStream.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.