Package: org.apache.groovy.io

## [Java] Class StringBuilderWriter

- org.apache.groovy.io.StringBuilderWriter

- All Implemented Interfaces and Traits:
    Serializable

      public class StringBuilderWriter
      extends Writer

  Copied from https://github.com/apache/commons-io/blob/master/src/main/java/org/apache/commons/io/output/StringBuilderWriter.java Writer implementation that outputs to a StringBuilder.

  NOTE: This implementation, as an alternative to `java.io.StringWriter`, provides an un-synchronized (i.e. for use in a single thread) implementation for better performance. For safe usage with multiple Threads then `java.io.StringWriter` should be used.

  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and description
    `StringBuilderWriter ()` Constructs a new StringBuilder instance with default capacity.
    `StringBuilderWriter (int capacity)` Constructs a new StringBuilder instance with the specified capacity.
    `StringBuilderWriter (StringBuilder builder)` Constructs a new instance with the specified StringBuilder.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `Writer` | `append(char value)` Appends a single character to this Writer.
    `` | `Writer` | `append(CharSequence value)` Appends a character sequence to this Writer.
    `` | `Writer` | `append(CharSequence value, int start, int end)` Appends a portion of a character sequence to the StringBuilder.
    `` | `void` | `close()` Closing this writer has no effect.
    `` | `void` | `flush()` Flushing this writer has no effect.
    `` | `StringBuilder` | `getBuilder()` Returns the underlying builder.
    `` | `String` | `toString()` Returns StringBuilder.toString.
    `` | `void` | `write(String value)` Writes a String to the StringBuilder.
    `` | `void` | `write(char[] value, int offset, int length)` Writes a portion of a character array to the StringBuilder.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Writer` | `append, append, append, append, append, append, write, write, write, write, write, close, flush, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Constructor Detail

    - #### public StringBuilderWriter()

      Constructs a new StringBuilder instance with default capacity.

    - #### public StringBuilderWriter(int capacity)

      Constructs a new StringBuilder instance with the specified capacity.

      Parameters:
        `capacity` - The initial capacity of the underlying StringBuilder

    - #### public StringBuilderWriter(StringBuilder builder)

      Constructs a new instance with the specified StringBuilder.

      If `builder` is null a new instance with default capacity will be created.

      Parameters:
        `builder` - The String builder. May be null.

  - ### Method Detail

    - #### @Override public Writer append(char value)

      Appends a single character to this Writer.

      Parameters:
        `value` - The character to append
      Returns:
        This writer instance

    - #### @Override public Writer append(CharSequence value)

      Appends a character sequence to this Writer.

      Parameters:
        `value` - The character to append
      Returns:
        This writer instance

    - #### @Override public Writer append(CharSequence value, int start, int end)

      Appends a portion of a character sequence to the StringBuilder.

      Parameters:
        `value` - The character to append
        `start` - The index of the first character
        `end` - The index of the last character + 1
      Returns:
        This writer instance

    - #### @Override public void close()

      Closing this writer has no effect.

    - #### @Override public void flush()

      Flushing this writer has no effect.

    - #### public StringBuilder getBuilder()

      Returns the underlying builder.

      Returns:
        The underlying builder

    - #### @Override public String toString()

      Returns StringBuilder.toString.

      Returns:
        The contents of the String builder.

    - #### @Override public void write(String value)

      Writes a String to the StringBuilder.

      Parameters:
        `value` - The value to write

    - #### @Override public void write(char[] value, int offset, int length)

      Writes a portion of a character array to the StringBuilder.

      Parameters:
        `value` - The value to write
        `offset` - The index of the first character
        `length` - The number of characters to write