public class LimitInputStream extends CountingInputStream
countin| Constructor and Description |
|---|
LimitInputStream(InputStream in,
long max)Create a LimitInputStream that limits total bytes read. |
| Modifier and Type | Method and Description |
|---|---|
int | available()Return the number of bytes available, limited by the remaining quota. |
int | read()Read a single byte, returning -1 if the limit has been reached. |
int | read(byte[] buf,
int off,
int len)Read bytes into a buffer, limited by the remaining quota. |
long | skip(long n)Skip bytes, limited by the remaining quota. |
getReadclose, mark, markSupported, read, resetpublic LimitInputStream(InputStream in, long max)
in - the underlying input streammax - the maximum number of bytes that may be readpublic int available()
throws IOExceptionavailable in class FilterInputStreamIOException - on I/O errorpublic int read()
throws IOExceptionread in class CountingInputStreamIOException - on I/O errorpublic int read(byte[] buf,
int off,
int len)
throws IOExceptionread in class CountingInputStreambuf - the buffer to read intooff - the start offset in the bufferlen - the maximum number of bytes to readIOException - on I/O errorpublic long skip(long n)
throws IOExceptionskip in class CountingInputStreamn - number of bytes to skipIOException - on I/O error