public final class CapturedPrintStream extends PrintStream
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.getInstance()out| Modifier and Type | Method and Description |
|---|---|
static CapturedPrintStream |
getInstance()
Instantiates a new
CapturedPrintStream. |
BufferedReader |
getReader()
Gets a
BufferedReader over the bytes written to this PrintStream. |
void |
reset()
Discards the captured output.
|
byte[] |
toByteArray()
Gets a copy of the content of this stream as a byte array.
|
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, writewritepublic static CapturedPrintStream getInstance()
CapturedPrintStream.CapturedPrintStreampublic BufferedReader getReader()
BufferedReader over the bytes written to this PrintStream.
The content of this stream is not altered by this method.BufferedReader over the bytes written to this streamreset()public void reset()
public byte[] toByteArray()
reset()Copyright © 2022. All rights reserved.