# Class StringWriter

java.lang.Object
java.io.Writer
java.io.StringWriter

All Implemented Interfaces:
  `java.lang.Appendable, java.lang.AutoCloseable`

public class StringWriter extends Writer implements java.lang.Appendable

- ## Field Summary

  ### Fields inherited from class Writer

  `lock`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringWriter()`
  `StringWriter(int initialSize)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `StringWriter`
  `append(char c)`
  `StringWriter`
  `append(java.lang.CharSequence csq)`
  `StringWriter`
  `append(java.lang.CharSequence csq, int start, int end)`
  `void`
  `close()`
  Close the stream, flushing it first.
  `void`
  `flush()`
  Flush the stream.
  `java.lang.StringBuffer`
  `getBuffer()`
  `java.lang.String`
  `toString()`
  `void`
  `write(char[] cbuf)`
  Write an array of characters.
  `void`
  `write(char[] cbuf, int off, int len)`
  Write a portion of an array of characters.
  `void`
  `write(int c)`
  Write a single character.
  `void`
  `write(java.lang.String str)`
  Write a string.
  `void`
  `write(java.lang.String str, int off, int len)`
  Write a portion of a string.

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

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

- ## Constructor Details

  - ### StringWriter

    public StringWriter()

  - ### StringWriter

    public StringWriter(int initialSize)

- ## Method Details

  - ### close

    public void close() throws IOException
    Description copied from class: `Writer`
    Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.
    Specified by:
      `close` in interface `java.lang.AutoCloseable`
    Specified by:
      `close` in class `Writer`
    Throws:
      `IOException`

  - ### flush

    public void flush() throws IOException
    Description copied from class: `Writer`
    Flush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
    Specified by:
      `flush` in class `Writer`
    Throws:
      `IOException`

  - ### write

    public void write(char[] cbuf, int off, int len) throws IOException
    Description copied from class: `Writer`
    Write a portion of an array of characters.
    Specified by:
      `write` in class `Writer`
    Throws:
      `IOException`

  - ### write

    public void write(java.lang.String str, int off, int len) throws IOException
    Description copied from class: `Writer`
    Write a portion of a string.
    Overrides:
      `write` in class `Writer`
    Throws:
      `IOException`

  - ### write

    public void write(int c) throws IOException
    Description copied from class: `Writer`
    Write a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored. Subclasses that intend to support efficient single-character output should override this method.
    Overrides:
      `write` in class `Writer`
    Throws:
      `IOException`

  - ### write

    public void write(java.lang.String str) throws IOException
    Description copied from class: `Writer`
    Write a string.
    Overrides:
      `write` in class `Writer`
    Throws:
      `IOException`

  - ### write

    public void write(char[] cbuf) throws IOException
    Description copied from class: `Writer`
    Write an array of characters.
    Overrides:
      `write` in class `Writer`
    Throws:
      `IOException`

  - ### toString

    public java.lang.String toString()
    Overrides:
      `toString` in class `java.lang.Object`

  - ### getBuffer

    public java.lang.StringBuffer getBuffer()

  - ### append

    public StringWriter append(char c)
    Specified by:
      `append` in interface `java.lang.Appendable`

  - ### append

    public StringWriter append(java.lang.CharSequence csq)
    Specified by:
      `append` in interface `java.lang.Appendable`

  - ### append

    public StringWriter append(java.lang.CharSequence csq, int start, int end)
    Specified by:
      `append` in interface `java.lang.Appendable`