public abstract class AbstractLimitedInputStream extends FilterInputStream implements com.helger.commons.state.ICloseable
in| Constructor and Description |
|---|
AbstractLimitedInputStream(InputStream aIS,
long nSizeMax)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this input stream and releases any system resources associated with
the stream.
|
boolean |
isClosed()
Returns, whether this stream is already closed.
|
protected abstract void |
onLimitExceeded(long nSizeMax,
long nCount)
Called to indicate, that the input streams limit has been exceeded.
|
int |
read()
Reads the next byte of data from this input stream.
|
int |
read(byte[] b,
int nOfs,
int nLen)
Reads up to
len bytes of data from this input stream into an
array of bytes. |
available, mark, markSupported, read, reset, skippublic AbstractLimitedInputStream(@Nonnull InputStream aIS, @Nonnegative long nSizeMax)
aIS - The input stream, which shall be limited.nSizeMax - The limit; no more than this number of bytes shall be returned by
the source stream.protected abstract void onLimitExceeded(@Nonnegative long nSizeMax, @Nonnegative long nCount) throws IOException
nSizeMax - The input streams limit, in bytes.nCount - The actual number of bytes.IOException - The called method is expected to raise an IOException.public int read()
throws IOException
int in the range 0 to
255. If no byte is available because the end of the stream has
been reached, the value -1 is returned. This method blocks
until input data is available, the end of the stream is detected, or an
exception is thrown.
This method simply performs in.read() and returns the result.
read in class FilterInputStream-1 if the end of the stream
is reached.IOException - if an I/O error occurs.FilterInputStreampublic int read(@Nonnull byte[] b, @Nonnegative int nOfs, @Nonnegative int nLen) throws IOException
len bytes of data from this input stream into an
array of bytes. If len is not zero, the method blocks until
some input is available; otherwise, no bytes are read and 0 is
returned.
This method simply performs in.read(b, off, len) and returns
the result.
read in class FilterInputStreamb - the buffer into which the data is read.nOfs - The start offset in the destination array b.nLen - the maximum number of bytes read.-1
if there is no more data because the end of the stream has been
reached.IndexOutOfBoundsException - If off is negative, len is negative,
or len is greater than b.length - offIOException - if an I/O error occurs.FilterInputStreampublic boolean isClosed()
throws IOException
isClosed in interface com.helger.commons.state.ICloseableIOException - An I/O error occurred.public void close()
throws IOException
in.close().close in interface com.helger.commons.state.ICloseableclose in interface Closeableclose in interface AutoCloseableclose in class FilterInputStreamIOException - if an I/O error occurs.FilterInputStreamCopyright © 2014–2019 Philip Helger. All rights reserved.