bb.io
Class PrintWriterStoring
java.lang.Object
java.io.Writer
java.io.PrintWriter
bb.io.PrintWriterStoring
- All Implemented Interfaces:
- Closeable, Flushable, Appendable
public class PrintWriterStoring
- extends PrintWriter
PrintWriter subclass that writes all chars to an internal char buffer.
This data is stored indefinately until it is retrieved and cleared by calling getString
.
Motivation: this class is typically used for debugging/test purposes when output from a PrintWriter needs to be captured.
This class is multithread safe: every method is synchronized on Writer.lock
.
- Author:
- Brent Boyer
Nested Class Summary |
static class |
PrintWriterStoring.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Method Summary |
String |
getString()
Returns all the chars that have been written so far to this instance as a new String. |
Methods inherited from class java.io.PrintWriter |
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
caw
private final CharArrayWriter caw
PrintWriterStoring
public PrintWriterStoring()
getString
public String getString()
- Returns all the chars that have been written so far to this instance as a new String.
Side effect: before return, clears the internal char buffer.