Package be.gaudry.swing.utils.console
Class MessageConsole.ConsoleOutputStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
be.gaudry.swing.utils.console.MessageConsole.ConsoleOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Enclosing class:
- MessageConsole
Class to intercept output from a PrintStream and add it to a Document.
The output can optionally be redirected to a different PrintStream. The
text displayed in the Document can be color coded to indicate the output
source.
-
Field Summary
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
-
Constructor Summary
ConstructorDescriptionConsoleOutputStream(Color textColor, PrintStream printStream)
Specify the option text color and PrintStream -
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Override this method to intercept the output text.Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, toString, toString, write, write, writeBytes, writeTo
Methods inherited from class java.io.OutputStream
nullOutputStream, write
-
Constructor Details
-
ConsoleOutputStream
Specify the option text color and PrintStream
-
-
Method Details
-
flush
public void flush()Override this method to intercept the output text. Each line of text output will actually involve invoking this method twice: a) for the actual text message b) for the newLine string The message will be treated differently depending on whether the line will be appended or inserted into the Document- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
-