java.lang.Object
java.io.Writer
i2p.susi.util.StringBuilderWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class StringBuilderWriterextends Writer
Writer implementation backed by StringBuilder.
  • Field Details

    • buf

      private final StringBuilder buf
      The builder this writer appends to.
  • Constructor Details

    • StringBuilderWriter

      public StringBuilderWriter()
      Create a StringBuilderWriter with default capacity.
    • StringBuilderWriter

      public StringBuilderWriter(int capacity)
      Create a StringBuilderWriter with specified capacity.
      Parameters:
      capacity - the initial capacity
  • Method Details

    • append

      public Writer append(char c)
      Append a character.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
      Parameters:
      c - the character to append
      Returns:
      this writer, for chaining
    • append

      public Writer append(CharSequence str)
      Append a character sequence.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
      Parameters:
      str - the character sequence to append
      Returns:
      this writer, for chaining
    • append

      public Writer append(CharSequence str, int off, int len)
      Append a portion of a character sequence.
      Specified by:
      append in interface Appendable
      Overrides:
      append in class Writer
      Parameters:
      str - the character sequence
      off - the start offset
      len - the number of characters
      Returns:
      this writer, for chaining
    • write

      public void write(char[] cbuf)
      Write a character array.
      Overrides:
      write in class Writer
      Parameters:
      cbuf - the characters to write
    • write

      public void write(char[] cbuf, int off, int len)
      Write a portion of a character array.
      Specified by:
      write in class Writer
      Parameters:
      cbuf - the characters to write
      off - the start offset
      len - the number of characters
    • write

      public void write(int c)
      Write a single character.
      Overrides:
      write in class Writer
      Parameters:
      c - the character to write
    • write

      public void write(String str)
      Write a string.
      Overrides:
      write in class Writer
      Parameters:
      str - the string to write
    • write

      public void write(String str, int off, int len)
      Write a portion of a string.
      Overrides:
      write in class Writer
      Parameters:
      str - the string
      off - the start offset
      len - the number of characters
    • close

      public void close()
      Does nothing.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Writer
    • flush

      public void flush()
      Does nothing.
      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class Writer
    • getBuilder

      public StringBuilder getBuilder()
      Get the underlying StringBuilder.
      Returns:
      the builder holding everything written so far, never null
    • toString

      public String toString()
      Overrides:
      toString in class Object