Package org.apache.commons.io.output
Class ChunkedWriter
- java.lang.Object
-
- java.io.Writer
-
- java.io.FilterWriter
-
- org.apache.commons.io.output.ChunkedWriter
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
public class ChunkedWriter extends java.io.FilterWriter
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
-
-
Constructor Summary
Constructors Constructor Description ChunkedWriter(java.io.Writer writer)
Creates a new writer that uses a chunk size ofDEFAULT_CHUNK_SIZE
ChunkedWriter(java.io.Writer writer, int chunkSize)
Creates a new writer that uses the specified chunk size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
write(char[] data, int srcOffset, int length)
writes the data buffer in chunks to the underlying writer
-
-
-
Constructor Detail
-
ChunkedWriter
public ChunkedWriter(java.io.Writer writer, int chunkSize)
Creates a new writer that uses the specified chunk size.- Parameters:
writer
- the writer to wrapchunkSize
- the chunk size to use; must be a positive number.- Throws:
java.lang.IllegalArgumentException
- if the chunk size is <= 0
-
ChunkedWriter
public ChunkedWriter(java.io.Writer writer)
Creates a new writer that uses a chunk size ofDEFAULT_CHUNK_SIZE
- Parameters:
writer
- the writer to wrap
-
-
Method Detail
-
write
public void write(char[] data, int srcOffset, int length) throws java.io.IOException
writes the data buffer in chunks to the underlying writer- Overrides:
write
in classjava.io.FilterWriter
- Parameters:
data
- The datasrcOffset
- the offsetlength
- the number of bytes to write- Throws:
java.io.IOException
- upon error
-
-