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:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
public class ChunkedOutputStream extends java.io.FilterOutputStreamOutputStream 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.To build an instance, see
ChunkedOutputStream.Builder- Since:
- 2.5
- See Also:
ChunkedOutputStream.Builder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classChunkedOutputStream.BuilderBuilds a newUnsynchronizedByteArrayOutputStream.
-
Constructor Summary
Constructors Constructor Description ChunkedOutputStream(java.io.OutputStream stream)Deprecated.ChunkedOutputStream(java.io.OutputStream stream, int chunkSize)Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ChunkedOutputStream.Builderbuilder()Constructs a newChunkedOutputStream.Builder.voidwrite(byte[] data, int srcOffset, int length)Writes the data buffer in chunks to the underlying stream
-
-
-
Constructor Detail
-
ChunkedOutputStream
@Deprecated public ChunkedOutputStream(java.io.OutputStream stream)
Deprecated.Constructs a new stream that uses a chunk size ofIOUtils.DEFAULT_BUFFER_SIZE.- Parameters:
stream- the stream to wrap
-
ChunkedOutputStream
@Deprecated public ChunkedOutputStream(java.io.OutputStream stream, int chunkSize)Deprecated.Constructs 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:
java.lang.IllegalArgumentException- if the chunk size is <= 0
-
-
Method Detail
-
builder
public static ChunkedOutputStream.Builder builder()
Constructs a newChunkedOutputStream.Builder.- Returns:
- a new
ChunkedOutputStream.Builder. - Since:
- 2.13.0
-
write
public void write(byte[] data, int srcOffset, int length) throws java.io.IOExceptionWrites the data buffer in chunks to the underlying stream- Overrides:
writein classjava.io.FilterOutputStream- Parameters:
data- the data to writesrcOffset- the offsetlength- the length of data to write- Throws:
java.io.IOException- if an I/O error occurs.
-
-