public final class StringBuilderWriter extends Writer
StringWriter, but uses a StringBuilder instead to avoid synchronization overhead.
Note that this class is NOT thread safe.
| Constructor and Description |
|---|
StringBuilderWriter()
Create a new string writer using the default initial string-builder size.
|
StringBuilderWriter(int initialSize)
Create a new string writer using the specified initial string-builder size.
|
StringBuilderWriter(StringBuilder sb)
Create a new string writer around an existing string builder.
|
| Modifier and Type | Method and Description |
|---|---|
StringBuilderWriter |
append(char c) |
StringBuilderWriter |
append(CharSequence csq) |
StringBuilderWriter |
append(CharSequence csq,
int start,
int end) |
void |
close() |
void |
flush() |
String |
toString() |
void |
write(char[] cbuf,
int start,
int length) |
void |
write(int c) |
void |
write(String str) |
void |
write(String str,
int off,
int len) |
public StringBuilderWriter()
public StringBuilderWriter(StringBuilder sb)
sb - The string builder being wrapped.public StringBuilderWriter(int initialSize)
initialSize - The number of char values that will fit into this buffer before it is automatically expanded.IllegalArgumentException - If initialSize is negative.public StringBuilderWriter append(CharSequence csq)
append in interface Appendableappend in class Writerpublic StringBuilderWriter append(CharSequence csq, int start, int end)
append in interface Appendableappend in class Writerpublic StringBuilderWriter append(char c)
append in interface Appendableappend in class Writerpublic void flush()
public void close() throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class WriterIOExceptionCopyright © 2018 Apache. All rights reserved.