public class LimitedInputStream extends FilterInputStream
InputStream wrapper that limits the bytes to read from the wrapped
stream.
| 限定符和类型 | 字段和说明 |
|---|---|
protected int |
m_amountOfBytesReadable
The amount of remaining bytes to allow reading.
|
in| 构造器和说明 |
|---|
LimitedInputStream(InputStream in,
int limit)
Construct an instance that wraps the given input stream and decorates it
with the the functionality to limit the amounts of bytes readable to the
given limit.
|
| 限定符和类型 | 方法和说明 |
|---|---|
int |
available() |
int |
read()
Read a byte.
|
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from this input stream into an
array of bytes. |
long |
skip(long howManyBytes) |
close, mark, markSupported, read, resetprotected int m_amountOfBytesReadable
public LimitedInputStream(InputStream in, int limit)
in - the input stream to limit.limit - the amount of bytes that may be read from the given input stream.public int available()
throws IOException
available 在类中 FilterInputStreamIOExceptionFilterInputStream.available()public int read()
throws IOException
read 在类中 FilterInputStreamIOExceptionFilterInputStream.read()public int read(byte[] b,
int off,
int len)
throws IOException
len bytes of data from this input stream into an
array of bytes. This method blocks until some input is available.
This method simply performs in.read(b, off, len) and returns
the result.
Additionally not only an EOF will limit the amount of bytes to read but also reaching the limit of this instance.
read 在类中 FilterInputStreamIOExceptionFilterInputStream.read(byte[], int, int)public long skip(long howManyBytes)
throws IOException
skip 在类中 FilterInputStreamIOExceptionCopyright © 2016. All rights reserved.