Package org.apache.commons.io.output

# Class FilterCollectionWriter

java.lang.Object
java.io.Writer
org.apache.commons.io.output.FilterCollectionWriter

All Implemented Interfaces:
  `Closeable`, `Flushable`, `Appendable`, `AutoCloseable`

Direct Known Subclasses:
  `ProxyCollectionWriter`

public class FilterCollectionWriter extends Writer
Abstract class for writing filtered character streams to a `Collection` of writers. This is in contrast to `FilterWriter` which is backed by a single `Writer`.

This abstract class provides default methods that pass all requests to the contained writers. Subclasses should likely override some of these methods.

The class `Writer` defines method signatures with `throws` `IOException`, which in this class are actually `IOExceptionList` containing a list of `IOIndexedException`.

Since:
  2.7

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final Collection<Writer>`
  `EMPTY_WRITERS`
  Empty and immutable collection of writers.
  `protected final Collection<Writer>`
  `writers`
  The underlying writers.

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

  `lock`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `FilterCollectionWriter(Writer... writers)`
  Constructs a new filtered collection writer.
  `protected`
  `FilterCollectionWriter(Collection<Writer> writers)`
  Constructs a new filtered collection writer.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Writer`
  `append(char c)`
  `Writer`
  `append(CharSequence csq)`
  `Writer`
  `append(CharSequence csq, int start, int end)`
  `void`
  `close()`
  `void`
  `flush()`
  Flushes the stream.
  `void`
  `write(char[] cbuf)`
  `void`
  `write(char[] cbuf, int off, int len)`
  Writes a portion of an array of characters.
  `void`
  `write(int c)`
  Writes a single character.
  `void`
  `write(String str)`
  `void`
  `write(String str, int off, int len)`
  Writes a portion of a string.

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

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

- ## Field Details

  - ### EMPTY_WRITERS

    protected final Collection<Writer> EMPTY_WRITERS
    Empty and immutable collection of writers.

  - ### writers

    protected final Collection<Writer> writers
    The underlying writers.

- ## Constructor Details

  - ### FilterCollectionWriter

    protected FilterCollectionWriter(Collection<Writer> writers)
    Constructs a new filtered collection writer.
    Parameters:
      `writers` - Writers to provide the underlying targets.

  - ### FilterCollectionWriter

    protected FilterCollectionWriter(Writer... writers)
    Constructs a new filtered collection writer.
    Parameters:
      `writers` - Writers to provide the underlying targets.

- ## Method Details

  - ### append

    public Writer append(char c) throws IOException
    Specified by:
      `append` in interface `Appendable`
    Overrides:
      `append` in class `Writer`
    Throws:
      `IOException`

  - ### append

    public Writer append(CharSequence csq) throws IOException
    Specified by:
      `append` in interface `Appendable`
    Overrides:
      `append` in class `Writer`
    Throws:
      `IOException`

  - ### append

    public Writer append(CharSequence csq, int start, int end) throws IOException
    Specified by:
      `append` in interface `Appendable`
    Overrides:
      `append` in class `Writer`
    Throws:
      `IOException`

  - ### close

    public void close() throws IOException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Closeable`
    Specified by:
      `close` in class `Writer`
    Throws:
      `IOException`

  - ### flush

    public void flush() throws IOException
    Flushes the stream.
    Specified by:
      `flush` in interface `Flushable`
    Specified by:
      `flush` in class `Writer`
    Throws:
      `IOException` - If an I/O error occurs

  - ### write

    public void write(char[] cbuf) throws IOException
    Overrides:
      `write` in class `Writer`
    Throws:
      `IOException`

  - ### write

    public void write(char[] cbuf, int off, int len) throws IOException
    Writes a portion of an array of characters.
    Specified by:
      `write` in class `Writer`
    Parameters:
      `cbuf` - Buffer of characters to be written
      `off` - Offset from which to start reading characters
      `len` - Number of characters to be written
    Throws:
      `IOException` - If an I/O error occurs

  - ### write

    public void write(int c) throws IOException
    Writes a single character.
    Overrides:
      `write` in class `Writer`
    Throws:
      `IOException` - If an I/O error occurs

  - ### write

    public void write(String str) throws IOException
    Overrides:
      `write` in class `Writer`
    Throws:
      `IOException`

  - ### write

    public void write(String str, int off, int len) throws IOException
    Writes a portion of a string.
    Overrides:
      `write` in class `Writer`
    Parameters:
      `str` - String to be written
      `off` - Offset from which to start reading characters
      `len` - Number of characters to be written
    Throws:
      `IOException` - If an I/O error occurs