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
ConstructorsConstructorDescriptionStringBuilderWriter(int initialCapacity) StringBuilderWriter(StringBuilder buffer) -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) append(CharSequence csq) append(CharSequence csq, int start, int end) voidclose()Does nothing on close.voidflush()Does nothing on flush.Gets theStringBuilderused as the buffer.toString()Gets the captured body as a String.voidwrite(char[] cbuf) voidwrite(char[] cbuf, int off, int len) voidwrite(int c) voidvoidMethods 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:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
append
- Specified by:
appendin interfaceAppendable- Overrides:
appendin classWriter
-
flush
public void flush()Does nothing on flush. -
close
public void close()Does nothing on close. -
getBuffer
Gets theStringBuilderused as the buffer. -
toString
Gets the captured body as a String. This is equivalent togetBuffer().toString().
-
