Package org.terracotta.utilities.io
Class CapturedPrintStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.PrintStream
org.terracotta.utilities.io.CapturedPrintStream
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
Extends
PrintStream to capture the output to an in-memory buffer.
The captured stream is available by calling getReader().
UTF-8 is used for encoding and decoding the stream
content.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CapturedPrintStreamInstantiates a newCapturedPrintStream.Gets aBufferedReaderover the bytes written to thisPrintStream.voidreset()Discards the captured output.byte[]Gets a copy of the content of this stream as a byte array.Methods inherited from class java.io.PrintStream
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, writeBytesMethods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
CapturedPrintStream
- Throws:
UnsupportedEncodingException
-
-
Method Details
-
getInstance
Instantiates a newCapturedPrintStream.- Returns:
- a new
CapturedPrintStream
-
getReader
Gets aBufferedReaderover the bytes written to thisPrintStream. The content of this stream is not altered by this method.- Returns:
- a new
BufferedReaderover the bytes written to this stream - See Also:
-
reset
public void reset()Discards the captured output. -
toByteArray
public byte[] toByteArray()Gets a copy of the content of this stream as a byte array. The content of this stream is not altered by this method.- Returns:
- a byte array containing a copy of the captured data
- See Also:
-