Class LimitedInputStream
java.lang.Object
java.io.InputStream
com.itextpdf.io.resolver.resource.LimitedInputStream
- All Implemented Interfaces:
-
Closeable,AutoCloseable
Implementation of the
InputStream abstract class, which is used to restrict reading bytes from input stream i.e. if more bytes are read than the readingByteLimit, an ReadingByteLimitException exception will be thrown.
Note that the readingByteLimit is not taken into account in the skip(long), available(), InputStream.mark(int) and InputStream.reset() methods.
-
Constructor Summary
ConstructorsConstructorDescriptionLimitedInputStream(InputStream inputStream, long readingByteLimit) Creates a newLimitedInputStreaminstance. -
Method Summary
Methods inherited from class java.io.InputStream
mark, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Constructor Details
-
LimitedInputStream
Creates a newLimitedInputStreaminstance.- Parameters:
-
inputStream- the input stream, the reading of bytes from which will be limited -
readingByteLimit- the reading byte limit, must not be less than zero
-
-
Method Details
-
read
- Specified by:
-
readin classInputStream - Throws:
-
IOException
-
read
- Overrides:
-
readin classInputStream - Throws:
-
IOException
-
read
- Overrides:
-
readin classInputStream - Throws:
-
IOException
-
close
- Specified by:
-
closein interfaceAutoCloseable - Specified by:
-
closein interfaceCloseable - Overrides:
-
closein classInputStream - Throws:
-
IOException
-
skip
- Overrides:
-
skipin classInputStream - Throws:
-
IOException
-
available
- Overrides:
-
availablein classInputStream - Throws:
-
IOException
-
markSupported
public boolean markSupported()- Overrides:
-
markSupportedin classInputStream
-
getReadingByteLimitExceptionSupplier
Returns a supplier of the exception that will be thrown when the reading byte limit is violated.- Returns:
- a supplier of the exception
-