Class ChunkedWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
org.apache.commons.io.output.ChunkedWriter
- All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Writer 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 FilterWriter
out -
Constructor Summary
ConstructorsConstructorDescriptionChunkedWriter(Writer writer) Constructs a new writer that uses a chunk size ofDEFAULT_CHUNK_SIZEChunkedWriter(Writer writer, int chunkSize) Constructs a new writer that uses the specified chunk size. -
Method Summary
Modifier and TypeMethodDescriptionvoidwrite(char[] data, int srcOffset, int length) Writes the data buffer in chunks to the underlying writer.Methods inherited from class FilterWriter
close, flush, write, write
-
Constructor Details
-
ChunkedWriter
Constructs a new writer that uses a chunk size ofDEFAULT_CHUNK_SIZE- Parameters:
writer- the writer to wrap.
-
ChunkedWriter
Constructs a new writer that uses the specified chunk size.- Parameters:
writer- the writer to wrap.chunkSize- the chunk size to use; must be a positive number.- Throws:
IllegalArgumentException- if the chunk size is <= 0.
-
-
Method Details
-
write
Writes the data buffer in chunks to the underlying writer.- Overrides:
writein classFilterWriter- Parameters:
data- The data.srcOffset- the offset.length- the number of bytes to write.- Throws:
NullPointerException- if the data isnull.IndexOutOfBoundsException- ifsrcOffsetorlengthare negative, or ifsrcOffset + lengthis greater thandata.length.IOException- If an I/O error occurs.
-