public class LimitedInputStream extends FilterInputStream
FilterInputStream
实现Modifier and Type | Field and Description |
---|---|
protected long |
limit |
in
Constructor and Description |
---|
LimitedInputStream(InputStream in,
long limit)
构造
|
LimitedInputStream(InputStream in,
long limit,
boolean throwWhenReachLimit)
构造
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
long |
skip(long len) |
close, mark, markSupported, read, reset
public LimitedInputStream(InputStream in, long limit)
in
- InputStream
limit
- 限制最大读取量,单位bytepublic LimitedInputStream(InputStream in, long limit, boolean throwWhenReachLimit)
in
- InputStream
limit
- 限制最大读取量,单位bytethrowWhenReachLimit
- 是否在达到限制时抛出异常,false
则读取到限制后返回-1public int read() throws IOException
read
in class FilterInputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class FilterInputStream
IOException
public long skip(long len) throws IOException
skip
in class FilterInputStream
IOException
public int available() throws IOException
available
in class FilterInputStream
IOException
Copyright © 2025. All rights reserved.