public class StringBuilderWriter extends Writer
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.
Constructor and description |
---|
StringBuilderWriter
() Constructs a new StringBuilder instance with default capacity. |
StringBuilderWriter
(int capacity) Constructs a new StringBuilder instance with the specified capacity. |
StringBuilderWriter
(StringBuilder builder) Constructs a new instance with the specified StringBuilder. |
Type Params | Return Type | Name and description |
---|---|---|
|
Writer |
append(char value) Appends a single character to this Writer. |
|
Writer |
append(CharSequence value) Appends a character sequence to this Writer. |
|
Writer |
append(CharSequence value, int start, int end) Appends a portion of a character sequence to the StringBuilder. |
|
void |
close() Closing this writer has no effect. |
|
void |
flush() Flushing this writer has no effect. |
|
StringBuilder |
getBuilder() Returns the underlying builder. |
|
String |
toString() Returns StringBuilder.toString. |
|
void |
write(String value) Writes a String to the StringBuilder. |
|
void |
write(char[] value, int offset, int length) Writes a portion of a character array to the StringBuilder. |
Methods inherited from class | Name |
---|---|
class Writer |
append, append, append, append, append, append, write, write, write, write, write, close, flush, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
class Object |
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Constructs a new StringBuilder instance with default capacity.
Constructs a new StringBuilder instance with the specified capacity.
capacity
- The initial capacity of the underlying StringBuilderConstructs a new instance with the specified StringBuilder.
If builder
is null a new instance with default capacity will be created.
builder
- The String builder. May be null.Appends a single character to this Writer.
value
- The character to appendAppends a character sequence to this Writer.
value
- The character to appendAppends a portion of a character sequence to the StringBuilder.
value
- The character to appendstart
- The index of the first characterend
- The index of the last character + 1Closing this writer has no effect.
Flushing this writer has no effect.
Returns the underlying builder.
Returns StringBuilder.toString.
Writes a String to the StringBuilder.
value
- The value to writeWrites a portion of a character array to the StringBuilder.
value
- The value to writeoffset
- The index of the first characterlength
- The number of characters to writeCopyright © 2003-2019 The Apache Software Foundation. All rights reserved.