public class LimitedInputStream extends InputStream
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 and Description |
|---|
LimitedInputStream(InputStream inputStream,
long readingByteLimit)
Creates a new
LimitedInputStream instance. |
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
protected Supplier<ITextException> |
getReadingByteLimitExceptionSupplier()
Returns a supplier of the exception that will be thrown when the reading byte limit is violated.
|
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
long |
skip(long n) |
mark, resetpublic LimitedInputStream(InputStream inputStream, long readingByteLimit)
LimitedInputStream instance.inputStream - the input stream, the reading of bytes from which will be limitedreadingByteLimit - the reading byte limit, must not be less than zeropublic int read()
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in class InputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class InputStreamIOExceptionpublic long skip(long n)
throws IOException
skip in class InputStreamIOExceptionpublic int available()
throws IOException
available in class InputStreamIOExceptionpublic boolean markSupported()
markSupported in class InputStreamprotected Supplier<ITextException> getReadingByteLimitExceptionSupplier()
Copyright © 1998–2025 Apryse Group NV. All rights reserved.