Package ej.hoka.io
Class ChunkedMessageBodyOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- ej.hoka.io.ChunkedMessageBodyOutputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class ChunkedMessageBodyOutputStream extends java.io.OutputStreamOutput 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 Summary
Constructors Constructor Description ChunkedMessageBodyOutputStream(java.io.OutputStream os)Creates a new instance ofChunkedMessageBodyOutputStreamusing the specifiedOutputStreamas the underlying OutputStream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close this output stream.voidflush()Writes the pending data and flush underlying stream.voidwrite(byte[] b, int off, int len)Writes the content of the byte arraybfrom the offsetoffin lengthlenin chunked encoding using the underlyingOutputStream.voidwrite(int b)Write one byte of data.
-
-
-
Constructor Detail
-
ChunkedMessageBodyOutputStream
public ChunkedMessageBodyOutputStream(java.io.OutputStream os)
Creates a new instance ofChunkedMessageBodyOutputStreamusing the specifiedOutputStreamas the underlying OutputStream.- Parameters:
os- the underlyingOutputStreamto use
-
-
Method Detail
-
close
public final void close() throws java.io.IOExceptionClose 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.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.OutputStream- Throws:
java.io.IOException- when an error occurs while closing the stream
-
flush
public final void flush() throws java.io.IOExceptionWrites the pending data and flush underlying stream.- Specified by:
flushin interfacejava.io.Flushable- Overrides:
flushin classjava.io.OutputStream- Throws:
java.io.IOException- when the connection is closed.
-
write
public final void write(byte[] b, int off, int len) throws java.io.IOExceptionWrites the content of the byte arraybfrom the offsetoffin lengthlenin chunked encoding using the underlyingOutputStream.- Overrides:
writein classjava.io.OutputStream- Parameters:
b- the byte arrayoff- the starting index in byte arrayblen- the number of bytes written to the underlying Output stream in chunked encoding.- Throws:
java.io.IOException- if the ChunkedMessageBodyOutputStream is already closed.
-
write
public final void write(int b) throws java.io.IOExceptionWrite 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.- Specified by:
writein classjava.io.OutputStream- Parameters:
b- the byte to write to the underlyingOutputStream- Throws:
java.io.IOException- if the ChunkedMessageBodyOutputStream is already closed.- See Also:
OutputStream.write(int)
-
-