public final class LimitedSizeInputStream
extends java.io.InputStream
Constructor and Description |
---|
LimitedSizeInputStream(java.io.InputStream stream,
long sizeLimit)
Wrap the given input stream so that limiting the number of bytes that can be read.
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
java.io.InputStream |
getInnerStream()
Get the input stream wrapped by this instance of
LimitedSizeInputStream . |
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
boolean |
sizeExceeded()
Tell whether the limit has already been exceeded or not.
|
long |
skip(long n) |
public LimitedSizeInputStream(java.io.InputStream stream, long sizeLimit) throws java.lang.NullPointerException
stream
- Stream to limit.sizeLimit
- Maximum number of bytes that can be read. If <=0 an InvalidParameterException
will be thrown.java.lang.NullPointerException
- If the input stream is missing.public final java.io.InputStream getInnerStream()
LimitedSizeInputStream
.public final boolean sizeExceeded()
Tell whether the limit has already been exceeded or not.
Note:
If true is returned, no more read will be allowed, and any attempt to read a byte will throw an ExceededSizeException
.
public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
public void mark(int readlimit) throws java.lang.UnsupportedOperationException
mark
in class java.io.InputStream
java.lang.UnsupportedOperationException
public boolean markSupported()
markSupported
in class java.io.InputStream
public void reset() throws java.io.IOException, java.lang.UnsupportedOperationException
reset
in class java.io.InputStream
java.io.IOException
java.lang.UnsupportedOperationException