public class BoundedInputStream extends InputStream
This relies on IOUtils' skip and read to try to fully read/skip inputstream.
Constructor and Description |
---|
BoundedInputStream(long max,
InputStream in) |
Modifier and Type | Method and Description |
---|---|
boolean |
hasHitBound() |
void |
mark(int readLimit) |
int |
read() |
int |
read(byte[] b)
Invokes the delegate's
read(byte[]) method. |
int |
read(byte[] b,
int off,
int len)
Invokes the delegate's
read(byte[], int, int) method. |
void |
reset() |
long |
skip(long n)
Invokes the delegate's
skip(long) method. |
available, close, markSupported
public BoundedInputStream(long max, InputStream in)
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b) throws IOException
read(byte[])
method.read
in class InputStream
b
- the buffer to read the bytes intoIOException
- if an I/O error occurspublic int read(byte[] b, int off, int len) throws IOException
read(byte[], int, int)
method.
This does not have the same guarantees as IOUtil's readFully()...be careful.
read
in class InputStream
b
- the buffer to read the bytes intooff
- The start offsetlen
- The number of bytes to readIOException
- if an I/O error occurspublic long skip(long n) throws IOException
skip(long)
method.
As with InputStream generally, this does not guarantee reading n bytes.
Use IOUtils' skipFully for that functionality.skip
in class InputStream
n
- the number of bytes to skipIOException
- if an I/O error occurspublic void reset() throws IOException
reset
in class InputStream
IOException
public void mark(int readLimit)
mark
in class InputStream
public boolean hasHitBound()
Copyright © 2007–2021 The Apache Software Foundation. All rights reserved.