Package org.apache.tika.io
Class BoundedInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.tika.io.BoundedInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class BoundedInputStream extends InputStream
Very slight modification of Commons' BoundedInputStream so that we can figure out if this hit the bound or not.
-
-
Constructor Summary
Constructors Constructor Description BoundedInputStream(long max, InputStream in)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasHitBound()
void
mark(int readLimit)
int
read()
int
read(byte[] b)
Invokes the delegate'sread(byte[])
method.int
read(byte[] b, int off, int len)
Invokes the delegate'sread(byte[], int, int)
method.void
reset()
long
skip(long n)
Invokes the delegate'sskip(long)
method.-
Methods inherited from class java.io.InputStream
available, close, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
BoundedInputStream
public BoundedInputStream(long max, InputStream in)
-
-
Method Detail
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
Invokes the delegate'sread(byte[])
method.- Overrides:
read
in classInputStream
- Parameters:
b
- the buffer to read the bytes into- Returns:
- the number of bytes read or -1 if the end of stream or the limit has been reached.
- Throws:
IOException
- if an I/O error occurs
-
read
public int read(byte[] b, int off, int len) throws IOException
Invokes the delegate'sread(byte[], int, int)
method.- Overrides:
read
in classInputStream
- Parameters:
b
- the buffer to read the bytes intooff
- The start offsetlen
- The number of bytes to read- Returns:
- the number of bytes read or -1 if the end of stream or the limit has been reached.
- Throws:
IOException
- if an I/O error occurs
-
skip
public long skip(long n) throws IOException
Invokes the delegate'sskip(long)
method.- Overrides:
skip
in classInputStream
- Parameters:
n
- the number of bytes to skip- Returns:
- the actual number of bytes skipped
- Throws:
IOException
- if an I/O error occurs
-
reset
public void reset() throws IOException
- Overrides:
reset
in classInputStream
- Throws:
IOException
-
mark
public void mark(int readLimit)
- Overrides:
mark
in classInputStream
-
hasHitBound
public boolean hasHitBound()
-
-