Package com.fasterxml.jackson.core.io
Class SegmentedStringWriter
java.lang.Object
java.io.Writer
com.fasterxml.jackson.core.io.SegmentedStringWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
Efficient alternative to
StringWriter
, based on using segmented
internal buffer. Initial input buffer is also recyclable.
This class is most useful when serializing JSON content as a String:
if so, instance of this class can be given as the writer to
JsonGenerator
.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) void
close()
void
flush()
Main access method that will construct a String that contains all the contents, release all internal buffers we may have, and return result String.void
write
(char[] cbuf) void
write
(char[] cbuf, int off, int len) void
write
(int c) void
void
Methods inherited from class java.io.Writer
nullWriter
-
Constructor Details
-
SegmentedStringWriter
-
-
Method Details
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
- Throws:
IOException
-
close
public void close() -
flush
public void flush() -
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Specified by:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
write
- Overrides:
write
in classWriter
- Throws:
IOException
-
getAndClear
Main access method that will construct a String that contains all the contents, release all internal buffers we may have, and return result String. Note that the method is not idempotent -- if called second time, will just return an empty String.- Returns:
- String that contains all aggregated content
- Throws:
IOException
- if there are general I/O or parse issues, including if the text is too large, seeStreamReadConstraints.Builder.maxStringLength(int)
-