java.lang.Object
java.io.Writer
com.aoapps.hodgepodge.io.StringBuilderWriter
- All Implemented Interfaces:
NoClose
,Closeable
,Flushable
,Appendable
,AutoCloseable
A
Writer
that buffers its content into a StringBuilder
.
This implementation is completely unsynchronized. Every method of Writer
that uses lock
has been overridden to ensure this.- Author:
- AO Industries, Inc.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionStringBuilderWriter
(int initialCapacity) StringBuilderWriter
(StringBuilder buffer) -
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) void
close()
Does nothing on close.void
flush()
Does nothing on flush.Gets theStringBuilder
used as the buffer.toString()
Gets the captured body as a 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
-
StringBuilderWriter
public StringBuilderWriter() -
StringBuilderWriter
public StringBuilderWriter(int initialCapacity) -
StringBuilderWriter
-
-
Method Details
-
write
public void write(int c) -
write
public void write(char[] cbuf) -
write
public void write(char[] cbuf, int off, int len) -
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
-
flush
public void flush()Does nothing on flush. -
close
public void close()Does nothing on close. -
getBuffer
Gets theStringBuilder
used as the buffer. -
toString
Gets the captured body as a String. This is equivalent togetBuffer().toString()
.
-