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.InputStreamjava.io.IOExceptionpublic int read(byte[] b)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic long skip(long n)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOExceptionpublic int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic void mark(int readlimit)
throws java.lang.UnsupportedOperationException
mark in class java.io.InputStreamjava.lang.UnsupportedOperationExceptionpublic boolean markSupported()
markSupported in class java.io.InputStreampublic void reset()
throws java.io.IOException,
java.lang.UnsupportedOperationException
reset in class java.io.InputStreamjava.io.IOExceptionjava.lang.UnsupportedOperationException