Package org.apache.groovy.io
Class StringBuilderWriter
java.lang.Object
java.io.Writer
org.apache.groovy.io.StringBuilderWriter
- All Implemented Interfaces:
- Closeable,- Flushable,- Serializable,- Appendable,- AutoCloseable
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
- See Also:
- 
Field Summary
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs a newStringBuilderinstance with default capacity.StringBuilderWriter(int capacity) Constructs a newStringBuilderinstance with the specified capacity.StringBuilderWriter(StringBuilder builder) Constructs a new instance with the specifiedStringBuilder.
- 
Method SummaryModifier and TypeMethodDescriptionappend(char value) Appends a single character to this Writer.append(CharSequence value) Appends a character sequence to this Writer.append(CharSequence value, int start, int end) Appends a portion of a character sequence to theStringBuilder.voidclose()Closing this writer has no effect.voidflush()Flushing this writer has no effect.Returns the underlying builder.toString()ReturnsStringBuilder.toString().voidwrite(char[] value, int offset, int length) Writes a portion of a character array to theStringBuilder.voidWrites a String to theStringBuilder.Methods inherited from class java.io.WriternullWriter, write, write, write
- 
Constructor Details- 
StringBuilderWriterpublic StringBuilderWriter()Constructs a newStringBuilderinstance with default capacity.
- 
StringBuilderWriterpublic StringBuilderWriter(int capacity) Constructs a newStringBuilderinstance with the specified capacity.- Parameters:
- capacity- The initial capacity of the underlying- StringBuilder
 
- 
StringBuilderWriterConstructs a new instance with the specifiedStringBuilder.If builderis null a new instance with default capacity will be created.- Parameters:
- builder- The String builder. May be null.
 
 
- 
- 
Method Details- 
appendAppends a single character to this Writer.- Specified by:
- appendin interface- Appendable
- Overrides:
- appendin class- Writer
- Parameters:
- value- The character to append
- Returns:
- This writer instance
 
- 
appendAppends a character sequence to this Writer.- Specified by:
- appendin interface- Appendable
- Overrides:
- appendin class- Writer
- Parameters:
- value- The character to append
- Returns:
- This writer instance
 
- 
appendAppends a portion of a character sequence to theStringBuilder.- Specified by:
- appendin interface- Appendable
- Overrides:
- appendin 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
 
- 
closepublic void close()Closing this writer has no effect.
- 
flushpublic void flush()Flushing this writer has no effect.
- 
writeWrites a String to theStringBuilder.
- 
writepublic void write(char[] value, int offset, int length) Writes a portion of a character array to theStringBuilder.
- 
getBuilderReturns the underlying builder.- Returns:
- The underlying builder
 
- 
toStringReturnsStringBuilder.toString().
 
-