Package org.apache.juneau.internal
Class StringBuilderWriter
java.lang.Object
java.io.Writer
org.apache.juneau.internal.StringBuilderWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Similar to
StringWriter
, but uses a StringBuilder
instead to avoid synchronization overhead.
Notes:
- This class is not thread safe.
See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate 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.Create a new string writer around an existing string builder. -
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) void
close()
void
flush()
toString()
void
write
(char[] cbuf, int start, int length) void
write
(int c) void
void
Methods inherited from class java.io.Writer
nullWriter, write
-
Constructor Details
-
StringBuilderWriter
public StringBuilderWriter()Create a new string writer using the default initial string-builder size. -
StringBuilderWriter
Create a new string writer around an existing string builder.- Parameters:
sb
- The string builder being wrapped.
-
StringBuilderWriter
Create a new string writer using the specified initial string-builder size.- Parameters:
initialSize
- The number of char values that will fit into this buffer before it is automatically expanded.- Throws:
IllegalArgumentException
- If initialSize is negative.
-
-
Method Details
-
write
-
write
-
write
-
write
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
toString
-
flush
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-