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
ConstructorsConstructorDescriptionCreate 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) voidclose()voidflush()toString()voidwrite(char[] cbuf, int start, int length) voidwrite(int c) voidvoidMethods 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:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
toString
-
flush
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classWriter- Throws:
IOException
-