Class FastStringWriter

java.lang.Object
java.io.Writer
com.sun.faces.io.FastStringWriter
All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

public class FastStringWriter extends Writer

This is based on StringWriter but backed by a StringBuilder instead.

This class is not thread safe.

  • Field Details

  • Constructor Details

    • FastStringWriter

      public FastStringWriter()

      Constructs a new FastStringWriter instance using the default capacity of 16.

    • FastStringWriter

      public FastStringWriter(int initialCapacity)

      Constructs a new FastStringWriter instance using the specified initialCapacity.

      Parameters:
      initialCapacity - specifies the initial capacity of the buffer
      Throws:
      IllegalArgumentException - if initialCapacity is less than zero
  • Method Details

    • write

      public void write(char[] cbuf, int off, int len) throws IOException

      Write a portion of an array of characters.

      Specified by:
      write in class Writer
      Parameters:
      cbuf - Array of characters
      off - Offset from which to start writing characters
      len - Number of characters to write
      Throws:
      IOException
    • flush

      public void flush() throws IOException

      This is a no-op.

      Specified by:
      flush in interface Flushable
      Specified by:
      flush in class Writer
      Throws:
      IOException
    • close

      public void close() throws IOException

      This is a no-op.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in class Writer
      Throws:
      IOException
    • write

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

      public void write(String str, int off, int len)
      Write a portion of a string.
      Overrides:
      write in class Writer
      Parameters:
      str - A String
      off - Offset from which to start writing characters
      len - Number of characters to write
    • getBuffer

      public StringBuilder getBuffer()
      Return the StringBuilder itself.
      Returns:
      StringBuilder holding the current buffer value.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the buffer's current value as a string.
    • reset

      public void reset()