Class StringBuilderWriter
java.lang.Object
java.io.Writer
org.json.StringBuilderWriter
- All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable
Performance optimised alternative for
StringWriter
using internally a StringBuilder instead of a StringBuffer.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new string builder writer using the default initial string-builder buffer size.StringBuilderWriter(int initialSize) Create a new string builder writer using the specified initial string-builder buffer size. -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(CharSequence csq) append(CharSequence csq, int start, int end) voidclose()voidflush()toString()voidwrite(char[] cbuf, int offset, int length) voidwrite(int c) voidvoid
-
Field Details
-
builder
-
-
Constructor Details
-
StringBuilderWriter
public StringBuilderWriter()Create a new string builder writer using the default initial string-builder buffer size. -
StringBuilderWriter
public StringBuilderWriter(int initialSize) Create a new string builder writer using the specified initial string-builder buffer size.- Parameters:
initialSize- The number ofcharvalues that will fit into this buffer before it is automatically expanded- Throws:
IllegalArgumentException- IfinitialSizeis 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
-