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 Appendable
append
in class Writer
public StringBuilderWriter append(CharSequence csq, int start, int end)
append
in interface Appendable
append
in class Writer
public StringBuilderWriter append(char c)
append
in interface Appendable
append
in class Writer
public void flush()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Writer
IOException
Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.