Package org.apache.commons.io.output
Class ChunkedOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.io.output.ChunkedOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
OutputStream which breaks larger output blocks into chunks.
Native code may need to copy the input array; if the write buffer
is very large this can cause OOME.
- Since:
- 2.5
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionChunkedOutputStream(OutputStream stream) Creates a new stream that uses a chunk size ofDEFAULT_CHUNK_SIZE.ChunkedOutputStream(OutputStream stream, int chunkSize) Creates a new stream that uses the specified chunk size. -
Method Summary
Modifier and TypeMethodDescriptionvoidwrite(byte[] data, int srcOffset, int length) Writes the data buffer in chunks to the underlying streamMethods inherited from class java.io.FilterOutputStream
close, flush, write, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
ChunkedOutputStream
Creates a new stream that uses the specified chunk size.- Parameters:
stream- the stream to wrapchunkSize- the chunk size to use; must be a positive number.- Throws:
IllegalArgumentException- if the chunk size is <= 0
-
ChunkedOutputStream
Creates a new stream that uses a chunk size ofDEFAULT_CHUNK_SIZE.- Parameters:
stream- the stream to wrap
-
-
Method Details
-
write
Writes the data buffer in chunks to the underlying stream- Overrides:
writein classFilterOutputStream- Parameters:
data- the data to writesrcOffset- the offsetlength- the length of data to write- Throws:
IOException- if an I/O error occurs.
-