Closing a StringBuilderWriter has no effect. The methods in this class
can be called after the stream has been closed without generating an
IOException.
This class is an alternative of JDK java.io.StringWriter.
It is backed up by StringBuilder for better performance without the
need of synchronization of a StringBuffer.
Instances of StringBuilderWriter are not safe for
use by multiple threads. If such synchronization is required then it is
recommended that java. be used.
| Modifier and Type | Field and Description |
|---|---|
| private final StringBuilder |
| Access | Constructor and Description |
|---|---|
| public | StringBuilderWriter()
Create a new string-builder writer using the default initial string-builder size. |
| public | StringBuilderWriter(int
The number of initialSize)char values that will fit into this StringBuilder
before it is automatically expandedCreate a new string-builder writer using the specified initial string-builder size. |
| public | StringBuilderWriter(StringBuilder
The string-builder to use. could be null and default-sized
string-builder will be created sb)Create a new string-builder writer using the specified string-builder. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract java. Implements java. Closing a |
| public void | flush()
Implements abstract java. Implements java. Flush the stream. |
| public StringBuilder | Returns: StringBuilder holding the current string-builder value.Return the string builder itself. |
| public String | |
| public void | write(int
int specifying a character to be written c)Overrides java. Writes a single character. |
| public void | write(char[]
Array of characters cbuf, int Offset from which to start writing characters off, int Number of characters to write len)Implements abstract java. Writes a portion of an array of characters. |
| public void | |
| public void | write(String
A String str, int Offset from which to start writing characters off, int Number of characters to write len)Overrides java. Writes a portion of a string. |
| sb | back to summary |
|---|---|
| private final StringBuilder sb | |
| StringBuilderWriter | back to summary |
|---|---|
| public StringBuilderWriter() Create a new string-builder writer using the default initial string-builder size. | |
| StringBuilderWriter | back to summary |
|---|---|
| public StringBuilderWriter(int initialSize) Create a new string-builder writer using the specified initial string-builder size.
| |
| StringBuilderWriter | back to summary |
|---|---|
| public StringBuilderWriter(StringBuilder sb) Create a new string-builder writer using the specified string-builder.
| |
| close | back to summary |
|---|---|
| public void close() Implements abstract java. Implements java. Closing a
| |
| flush | back to summary |
|---|---|
| public void flush() Implements abstract java. Implements java. Flush the stream. The
| |
| getBuilder | back to summary |
|---|---|
| public StringBuilder getBuilder() Return the string builder itself.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Return the buffer's current value as a string. | |
| write | back to summary |
|---|---|
| public void write(int c) throws IOException Overrides java. Writes a single character.
| |
| write | back to summary |
|---|---|
| public void write(char[] cbuf, int off, int len) throws IOException Implements abstract java. Writes a portion of an array of characters.
| |
| write | back to summary |
|---|---|
| public void write(String str) throws IOException Overrides java. Writes a string.
| |
| write | back to summary |
|---|---|
| public void write(String str, int off, int len) throws IOException Overrides java. Writes a portion of a string.
| |