public class ChunkedMessageBodyOutputStream extends OutputStream
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(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.
|
write
public ChunkedMessageBodyOutputStream(OutputStream os)
ChunkedMessageBodyOutputStream
using the specified OutputStream
as the
underlying OutputStream.os
- the underlying OutputStream
to usepublic final void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
- when an error occurs while closing the streampublic final void flush() throws IOException
flush
in interface Flushable
flush
in class OutputStream
IOException
- when the connection is closed.public final void write(byte[] b, int off, int len) throws IOException
b
from the offset off
in length len
in chunked encoding using the underlying OutputStream
.write
in class OutputStream
b
- the byte arrayoff
- the starting index in byte array b
len
- the number of bytes written to the underlying Output stream in chunked encoding.IOException
- if the ChunkedMessageBodyOutputStream is already closed.public final void write(int b) throws IOException
write
in class OutputStream
b
- the byte to write to the underlying OutputStream
IOException
- if the ChunkedMessageBodyOutputStream is already closed.OutputStream.write(int)