Package net.targetr.wtm3.io
Class ChunkedOutputStream
java.lang.Object
java.io.OutputStream
net.targetr.wtm3.io.ChunkedOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Writes a chunked output stream.
Used by HTTP/1.1 to transfer content of unknown length.
- Author:
- Dr Michael Gardiner
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
The size recommended when writing chunked data.static int
The time in milliseconds to delay writing data to ensure chunks are a sensible size. -
Constructor Summary
ConstructorsConstructorDescriptionDecorates an output stream to enable writing in chunks to a HTTP/1.1 client. -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Field Details
-
CHUNKING_BUFFER_SIZE
public static int CHUNKING_BUFFER_SIZEThe size recommended when writing chunked data. -
CHUNKING_WRITE_DELAY
public static int CHUNKING_WRITE_DELAYThe time in milliseconds to delay writing data to ensure chunks are a sensible size.
-
-
Constructor Details
-
ChunkedOutputStream
Decorates an output stream to enable writing in chunks to a HTTP/1.1 client.- Parameters:
out
- The chunked output stream.
-
-
Method Details
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
finish
Sends the last chunk but does not close the stream. This is important when keep-alive is enabled.- Throws:
IOException
- If there is an error writing the last chunk.
-
toString
-