public static class HTTPServer.LimitedInputStream extends FilterInputStream
LimitedInputStream provides access to a limited number
of consecutive bytes from the underlying InputStream, starting at its
current position. If this limit is reached, it behaves as though the end
of stream has been reached (although the underlying stream remains open
and may contain additional data).| Modifier and Type | Field and Description |
|---|---|
protected long |
limit |
protected boolean |
prematureEndException |
in| Constructor and Description |
|---|
LimitedInputStream(InputStream in,
long limit,
boolean prematureEndException)
Constructs a LimitedInputStream with the given underlying
input stream and limit.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
close() |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
long |
skip(long len) |
mark, read, resetprotected long limit
protected boolean prematureEndException
public LimitedInputStream(InputStream in, long limit, boolean prematureEndException)
in - the underlying input streamlimit - the maximum number of bytes that may be consumed from
the underlying stream before this stream ends. If zero or
negative, this stream will be at its end from initialization.prematureEndException - specifies the stream's behavior when
the underlying stream end is reached before the limit is
reached: if true, an exception is thrown, otherwise this
stream reaches its end as well (i.e. read() returns -1)NullPointerException - if the given stream is nullpublic int read()
throws IOException
read in class FilterInputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in class FilterInputStreamIOExceptionpublic long skip(long len)
throws IOException
skip in class FilterInputStreamIOExceptionpublic int available()
throws IOException
available in class FilterInputStreamIOExceptionpublic boolean markSupported()
markSupported in class FilterInputStreampublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class FilterInputStreamCopyright © 2021 freeutils.net. All rights reserved.