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 newLimitedInputStream
instance. -
Method Summary
Methods inherited from class java.io.InputStream
mark, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Constructor Details
-
LimitedInputStream
Creates a newLimitedInputStream
instance.- 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:
-
read
in classInputStream
- Throws:
-
IOException
-
read
- Overrides:
-
read
in classInputStream
- Throws:
-
IOException
-
read
- Overrides:
-
read
in classInputStream
- Throws:
-
IOException
-
close
- Specified by:
-
close
in interfaceAutoCloseable
- Specified by:
-
close
in interfaceCloseable
- Overrides:
-
close
in classInputStream
- Throws:
-
IOException
-
skip
- Overrides:
-
skip
in classInputStream
- Throws:
-
IOException
-
available
- Overrides:
-
available
in classInputStream
- Throws:
-
IOException
-
markSupported
public boolean markSupported()- Overrides:
-
markSupported
in 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
-