public class ChunkedMessageBodyOutputStream
extends java.io.OutputStream
Output Stream for writing HTTP 1.1 Chunked transfer encoding data.
Each chunk starts with the number of octets of the data it embeds, expressed as a hexadecimal numbers in ASCII and a terminating CRLF sequence, followed by the chunk data. The chunk is terminated by CRLF.
| Constructor and Description |
|---|
ChunkedMessageBodyOutputStream(java.io.OutputStream os)
Creates a new instance of
ChunkedMessageBodyOutputStream using the specified OutputStream as the
underlying OutputStream. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close this output stream.
|
void |
flush()
Writes the pending data and flush underlying stream.
|
void |
write(byte[] b,
int off,
int len)
Writes the content of the byte array
b from the offset off in length len
in chunked encoding using the underlying OutputStream. |
void |
write(int b)
Write one byte of data.
|
public ChunkedMessageBodyOutputStream(java.io.OutputStream os)
Creates a new instance of ChunkedMessageBodyOutputStream using the specified OutputStream as the
underlying OutputStream.
os - the underlying OutputStream to usepublic final void close()
throws java.io.IOException
Close this output stream. This method DOES NOT close the underlying stream (i.e. the TCP connection stream). It is the responsibility of the HTTPSession to close the underlying stream.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.OutputStreamjava.io.IOException - when an error occurs while closing the streampublic final void flush()
throws java.io.IOException
Writes the pending data and flush underlying stream.
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOException - when the connection is closed.public final void write(byte[] b,
int off,
int len)
throws java.io.IOException
Writes the content of the byte array b from the offset off in length len
in chunked encoding using the underlying OutputStream.
write in class java.io.OutputStreamb - the byte arrayoff - the starting index in byte array blen - the number of bytes written to the underlying Output stream in chunked encoding.java.io.IOException - if the ChunkedMessageBodyOutputStream is already closed.public final void write(int b)
throws java.io.IOException
Write one byte of data. The byte is not sent immediately, it is stored in a buffer and will be sent in a chunk when the buffer is full.
write in class java.io.OutputStreamb - the byte to write to the underlying OutputStreamjava.io.IOException - if the ChunkedMessageBodyOutputStream is already closed.OutputStream.write(int)