public class IdentityMessageBodyInputStream extends InputStream
InputStream
and all of the operations on
IdentityMessageBodyInputStream
are delegated to this underlying InputStream
.Constructor and Description |
---|
IdentityMessageBodyInputStream(InputStream is,
int bodyLength)
Creates a new instance of
IdentityMessageBodyInputStream with the InputStream is
with the predefined length bodyLength . |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the number of bytes that can be read (or skipped over) from this input stream without blocking.
|
void |
close()
Reads all remaining message body data and then close this input stream.
|
int |
read()
Reads the next byte of data from the input stream.
|
int |
read(byte[] data,
int offset,
int length)
Reads up to
length bytes of data from the underlying InputStream into an array of bytes. |
mark, markSupported, read, reset, skip
public IdentityMessageBodyInputStream(InputStream is, int bodyLength)
IdentityMessageBodyInputStream
with the InputStream
is
with the predefined length bodyLength
. The bodyLength
should be the maximum number of
bytes can be read from the InputStream.is
- the underlying InputStream
to read the body content of the HTTP message bodybodyLength
- the number of bytes can be read from the underlying InputStream.public int available() throws IOException
available
in class InputStream
IOException
- if IO Error occurs.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
- when an error occurs while closing the streampublic int read() throws IOException
read
in class InputStream
IOException
- If a premature EOF is reached, this stream is closed and an IOException is thrown.public int read(byte[] data, int offset, int length) throws IOException
length
bytes of data from the underlying InputStream
into an array of bytes. An
attempt is made to read as many as length
bytes, but the amount of bytes can be read from the
InputStream
could be less than length
, even 0
. The number of bytes actually
read are returned as an integer.read
in class InputStream
data
- the byte array to store the read bytes from the underlying InputStream
offset
- the starting index of byte array data
to store the byteslength
- the number of bytes intended to be read by the caller of this methodInputStream
. If the end of stream has been
reached, returns -1
IOException
- thrown in the following cases:
InputStream.read(byte[], int, int)