public class StringBuilderWriter
extends java.io.Writer
implements java.io.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.
Serialization is deprecated and will be removed in 3.0.
| 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(java.lang.StringBuilder builder)
Constructs a new instance with the specified
StringBuilder. |
| Modifier and Type | Method and Description |
|---|---|
java.io.Writer |
append(char value)
Appends a single character to this Writer.
|
java.io.Writer |
append(java.lang.CharSequence value)
Appends a character sequence to this Writer.
|
java.io.Writer |
append(java.lang.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.
|
java.lang.StringBuilder |
getBuilder()
Returns the underlying builder.
|
java.lang.String |
toString()
Returns
StringBuilder.toString(). |
void |
write(char[] value,
int offset,
int length)
Writes a portion of a character array to the
StringBuilder. |
void |
write(java.lang.String value)
Writes a String to the
StringBuilder. |
public StringBuilderWriter()
StringBuilder instance with default capacity.public StringBuilderWriter(int capacity)
StringBuilder instance with the specified capacity.capacity - The initial capacity of the underlying StringBuilderpublic StringBuilderWriter(java.lang.StringBuilder builder)
StringBuilder.
If builder is null a new instance with default capacity will be created.
builder - The String builder. May be null.public java.io.Writer append(char value)
append in interface java.lang.Appendableappend in class java.io.Writervalue - The character to appendpublic java.io.Writer append(java.lang.CharSequence value)
append in interface java.lang.Appendableappend in class java.io.Writervalue - The character to appendpublic java.io.Writer append(java.lang.CharSequence value,
int start,
int end)
StringBuilder.append in interface java.lang.Appendableappend in class java.io.Writervalue - The character to appendstart - The index of the first characterend - The index of the last character + 1public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerpublic void flush()
flush in interface java.io.Flushableflush in class java.io.Writerpublic java.lang.StringBuilder getBuilder()
public java.lang.String toString()
StringBuilder.toString().toString in class java.lang.Objectpublic void write(char[] value,
int offset,
int length)
StringBuilder.write in class java.io.Writervalue - The value to writeoffset - The index of the first characterlength - The number of characters to writepublic void write(java.lang.String value)
StringBuilder.write in class java.io.Writervalue - The value to writeCopyright © 2010 - 2023 Adobe. All Rights Reserved