org.apache.commons.io.output

Class StringBuilderWriter

  • All Implemented Interfaces:
    Closeable, Flushable, Serializable, Appendable, AutoCloseable


    public class StringBuilderWriterextends Writerimplements Serializable
    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
    Version:
    $Id: StringBuilderWriter.java 1722253 2015-12-30 00:36:12Z ggregory $
    See Also:
    Serialized Form
    • Constructor Detail

      • StringBuilderWriter

        public StringBuilderWriter()
        Constructs a new StringBuilder instance with default capacity.
      • StringBuilderWriter

        public StringBuilderWriter(int capacity)
        Constructs a new StringBuilder instance with the specified capacity.
        Parameters:
        capacity - The initial capacity of the underlying StringBuilder
      • StringBuilderWriter

        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

      • append

        public Writer append(char value)
        Appends a single character to this Writer.
        Specified by:
        append in interface Appendable
        Overrides:
        append in class Writer
        Parameters:
        value - The character to append
        Returns:
        This writer instance
      • append

        public Writer append(CharSequence value)
        Appends a character sequence to this Writer.
        Specified by:
        append in interface Appendable
        Overrides:
        append in class Writer
        Parameters:
        value - The character to append
        Returns:
        This writer instance
      • append

        public Writer append(CharSequence value,            int start,            int end)
        Appends a portion of a character sequence to the StringBuilder.
        Specified by:
        append in interface Appendable
        Overrides:
        append in class Writer
        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
      • flush

        public void flush()
        Flushing this writer has no effect.
        Specified by:
        flush in interface Flushable
        Specified by:
        flush in class Writer
      • write

        public void write(char[] value,         int offset,         int length)
        Writes a portion of a character array to the StringBuilder.
        Specified by:
        write in class Writer
        Parameters:
        value - The value to write
        offset - The index of the first character
        length - The number of characters to write
      • getBuilder

        public StringBuilder getBuilder()
        Returns the underlying builder.
        Returns:
        The underlying builder

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



NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14