public class ChunkedMessageBodyInputStream extends InputStream
Each chunk starts with the number of octets of the data it embeds, expressed as a hexadecimal number in ASCII, followed by optional parameters (chunk extension) and a terminating CRLF sequence, followed by the chunk data. The chunk is terminated by CRLF. If chunk extensions are provided, the chunk size is terminated by a semicolon followed with the extension name and an optional equal sign and value. (chunk extensions are skipped).
Constructor and Description |
---|
ChunkedMessageBodyInputStream(InputStream is)
Creates a new
ChunkedMessageBodyInputStream using the InputStream is as the underlying
data source. |
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns the number of available bytes to read.
|
void |
close()
Reads all remaining message body data and closes this input stream.
|
int |
read()
Reads the next byte from the InputStream used in the constructor.
|
int |
read(byte[] data,
int offset,
int length)
Reads up to
length bytes to the byte array data starting with offset . |
mark, markSupported, read, reset, skip
public ChunkedMessageBodyInputStream(InputStream is)
ChunkedMessageBodyInputStream
using the InputStream is
as the underlying
data source.is
- InputStream to read from.public int available() throws IOException
available
in class InputStream
IOException
- if the ChunkedMessageBodyInputStream
is already closed.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
- when the InputStream has already been closed.public int read(byte[] data, int offset, int length) throws IOException
length
bytes to the byte array data
starting with offset
. The
method tries to read length
bytes (if there are at least length
bytes in the
InputStream used in the constructor. Otherwise reads just the available number of bytes).read
in class InputStream
data
- the byte array to store the bytes read from the underlying InputStreamoffset
- the position in the byte array data
to store the bytes read from the InputStream.length
- number of bytes to store in the byte array data
(if the number of bytes available in the
InputStream are at least length
) If less than length
bytes are left in the
InputStream, only the remaining bytes are stored in the byte array data
.data
, or -1 if no bytes can be stored in the
byte array data
.IOException
- when the end of InputStream has already been reached.InputStream.read()