public class ContentLengthInputStream
extends java.io.InputStream
Constructor and Description |
---|
ContentLengthInputStream(java.io.InputStream in,
int contentLength)
Deprecated.
use
ContentLengthInputStream(InputStream, long)
Creates a new length limited stream |
ContentLengthInputStream(java.io.InputStream in,
long contentLength)
Creates a new length limited stream
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close()
Reads until the end of the known length of content.
|
int |
read()
Read the next byte from the stream
|
int |
read(byte[] b)
Read more bytes from the stream.
|
int |
read(byte[] b,
int off,
int len)
Does standard behavior, but
also notifies the watcher when the contents have been consumed.
|
long |
skip(long n)
Skips and discards a number of bytes from the input stream.
|
@Deprecated public ContentLengthInputStream(java.io.InputStream in, int contentLength)
ContentLengthInputStream(InputStream, long)
Creates a new length limited streamin
- The stream to wrapcontentLength
- The maximum number of bytes that can be read from
the stream. Subsequent read operations will return -1.public ContentLengthInputStream(java.io.InputStream in, long contentLength)
in
- The stream to wrapcontentLength
- The maximum number of bytes that can be read from
the stream. Subsequent read operations will return -1.public void close() throws java.io.IOException
Reads until the end of the known length of content.
Does not close the underlying socket input, but instead leaves it primed to parse the next response.
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.InputStream
java.io.IOException
- If an IO problem occurs.public int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
- If an IO problem occurspublic int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
b
- The byte array to fill.off
- Start filling at this position.len
- The number of bytes to attempt to read.java.io.IOException
- Should an error occur on the wrapped stream.public int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
b
- The byte array to put the new data in.java.io.IOException
- If an IO problem occurspublic long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
n
- The number of bytes to skip.java.io.IOException
- If an error occurs while skipping bytes.public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException