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:
    Closeable, Flushable, Appendable, AutoCloseable

      public class ChunkedWriter
      extends 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

- - ### Field Summary

    - ### Fields inherited from class java.io.FilterWriter

      `out`

    - ### Fields inherited from class java.io.Writer

      `lock`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ChunkedWriter(Writer writer)` Creates a new writer that uses a chunk size of `DEFAULT_CHUNK_SIZE`
    `ChunkedWriter(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 and Description
    --- | ---
    `void` | `write(char[] data, int srcOffset, int length)` writes the data buffer in chunks to the underlying writer

    - ### Methods inherited from class java.io.FilterWriter

      `close, flush, write, write`

    - ### Methods inherited from class java.io.Writer

      `append, append, append, write, write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ChunkedWriter

          public ChunkedWriter(Writer writer,
                               int chunkSize)

      Creates 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

    - #### ChunkedWriter

          public ChunkedWriter(Writer writer)

      Creates a new writer that uses a chunk size of `DEFAULT_CHUNK_SIZE`
      Parameters:
        `writer` - the writer to wrap

  - ### Method Detail

    - #### write

          public void write(char[] data,
                            int srcOffset,
                            int length)
                     throws IOException

      writes the data buffer in chunks to the underlying writer
      Overrides:
        `write` in class `FilterWriter`
      Parameters:
        `data` - The data
        `srcOffset` - the offset
        `length` - the number of bytes to write
      Throws:
        `IOException` - upon error

Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.