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.This relies on IOUtils' skip and read to try to fully read/skip inputstream. 
- 
- 
Constructor SummaryConstructors Constructor Description BoundedInputStream(long max, InputStream in)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()booleanhasHitBound()voidmark(int readLimit)booleanmarkSupported()intread()intread(byte[] b)Invokes the delegate'sread(byte[])method.intread(byte[] b, int off, int len)Invokes the delegate'sread(byte[], int, int)method.voidreset()longskip(long n)Invokes the delegate'sskip(long)method.- 
Methods inherited from class java.io.InputStreamclose, nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
 
- 
 
- 
- 
- 
Constructor Detail- 
BoundedInputStreampublic BoundedInputStream(long max, InputStream in)
 
- 
 - 
Method Detail- 
readpublic int read() throws IOException- Specified by:
- readin class- InputStream
- Throws:
- IOException
 
 - 
readpublic int read(byte[] b) throws IOExceptionInvokes the delegate'sread(byte[])method.- Overrides:
- readin class- InputStream
- 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
 
 - 
readpublic int read(byte[] b, int off, int len) throws IOExceptionInvokes the delegate'sread(byte[], int, int)method.This does not have the same guarantees as IOUtil's readFully()...be careful. - Overrides:
- readin class- InputStream
- Parameters:
- b- the buffer to read the bytes into
- off- The start offset
- len- 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
 
 - 
skippublic long skip(long n) throws IOExceptionInvokes the delegate'sskip(long)method. As with InputStream generally, this does not guarantee reading n bytes. Use IOUtils' skipFully for that functionality.- Overrides:
- skipin class- InputStream
- Parameters:
- n- the number of bytes to skip
- Returns:
- the actual number of bytes skipped
- Throws:
- IOException- if an I/O error occurs
 
 - 
resetpublic void reset() throws IOException- Overrides:
- resetin class- InputStream
- Throws:
- IOException
 
 - 
markpublic void mark(int readLimit) - Overrides:
- markin class- InputStream
 
 - 
hasHitBoundpublic boolean hasHitBound() 
 - 
availablepublic int available() throws IOException- Overrides:
- availablein class- InputStream
- Throws:
- IOException
 
 - 
markSupportedpublic boolean markSupported() - Overrides:
- markSupportedin class- InputStream
 
 
- 
 
-