Package org.json
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) void
close()
void
flush()
toString()
void
write
(char[] cbuf, int offset, int length) void
write
(int c) void
void
Methods inherited from class java.io.Writer
nullWriter, write
-
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 ofchar
values that will fit into this buffer before it is automatically expanded- Throws:
IllegalArgumentException
- IfinitialSize
is negative
-
-
Method Details
-
write
public void write(int c) -
write
public void write(char[] cbuf, int offset, int length) -
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
public void flush() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-