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 MessageConsole.ConsoleOutputStream extends ByteArrayOutputStream
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.
  • Constructor Details

    • ConsoleOutputStream

      public ConsoleOutputStream(Color textColor, PrintStream printStream)
      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 interface Flushable
      Overrides:
      flush in class OutputStream