org.apache.commons.io.output

## Class AppendableOutputStream<T extends Appendable>

- java.lang.Object
- - java.io.OutputStream
  - - org.apache.commons.io.output.AppendableOutputStream<T>

- Type Parameters:
    `T` - The type of the `Appendable` wrapped by this AppendableOutputStream.
  All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

      public class AppendableOutputStream<T extends Appendable>
      extends OutputStream

  OutputStream implementation that writes the data to an `Appendable` Object.

  For example, can be used with any `Writer` or a `StringBuilder` or `StringBuffer`.

  Since:
    2.5
  See Also:
    `Appendable`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AppendableOutputStream(T appendable)` Constructs a new instance with the specified appendable.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `getAppendable()` Return the target appendable.
    `void` | `write(int b)` Write a character to the underlying appendable.

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

      `close, flush, write, write`

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

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

- - ### Constructor Detail

    - #### AppendableOutputStream

          public AppendableOutputStream(T appendable)

      Constructs a new instance with the specified appendable.
      Parameters:
        `appendable` - the appendable to write to

  - ### Method Detail

    - #### getAppendable

          public T getAppendable()

      Return the target appendable.
      Returns:
        the target appendable

    - #### write

          public void write(int b)
                     throws IOException

      Write a character to the underlying appendable.
      Specified by:
        `write` in class `OutputStream`
      Parameters:
        `b` - the character to write
      Throws:
        `IOException` - upon error

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