public class LimitedInputStream extends InputStream
Content-Length
headers. This stream is
unsynchronized.LimitedOutputStream
Constructor and Description |
---|
LimitedInputStream(InputStream stream,
int lengthLimit)
Constructs a limited input stream.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Calls the wrapped stream.
|
void |
close()
Closes the underlying input stream.
|
void |
mark(int readlimit)
Calls the wrapped stream.
|
boolean |
markSupported()
Calls the wrapped stream.
|
int |
read()
Reads and returns a single byte from this input stream, or -1 if end of
file or the read limit has been encountered.
|
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from the input stream into
an array of bytes, possibly less if the read limit is reached. |
void |
reset()
Calls the wrapped stream.
|
String |
toString()
Returns a debug string.
|
read, skip
public LimitedInputStream(InputStream stream, int lengthLimit)
stream
- Must be non-null.lengthLimit
- limit of bytes of input.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
len
bytes of data from the input stream into
an array of bytes, possibly less if the read limit is reached.read
in class InputStream
IOException
public int available() throws IOException
available
in class InputStream
IOException
public boolean markSupported()
markSupported
in class InputStream
public void reset() throws IOException
reset
in class InputStream
IOException
public void mark(int readlimit)
mark
in class InputStream
public int read() throws IOException
read
in class InputStream
IOException
Copyright © 2013. All Rights Reserved.