Class TextAreaOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

    public class TextAreaOutputStream
    extends java.io.OutputStream
    Output stream that writes to a Swing component. Derived from https://www.codejava.net/java-se/swing/redirect-standard-output-streams-to-jtextarea

    Copyright (c) 2020-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See OpenTrafficSim License.

    Author:
    Alexander Verbraeck, Peter Knoppers, Wouter Schakel
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void awtWrite​(byte[] bytes, int offset, int length)
      Write to the textArea.
      void awtWrite​(int b)
      Write to the textArea.
      void write​(byte[] bytes)
      void write​(byte[] bytes, int offset, int length)
      void write​(int b)
      • Methods inherited from class java.io.OutputStream

        close, flush, nullOutputStream
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • awtWrite

        public void awtWrite​(byte[] bytes,
                             int offset,
                             int length)
        Write to the textArea. May only be called from within the AWT thread!
        Parameters:
        bytes - byte[]; bytes to write
        offset - int; offset within bytes of the first byte to write
        length - int; number of bytes to write
      • awtWrite

        public void awtWrite​(int b)
        Write to the textArea. May only be called from within the AWT thread!
        Parameters:
        b - int; byte to write
      • write

        public void write​(byte[] bytes,
                          int offset,
                          int length)
        Overrides:
        write in class java.io.OutputStream
      • write

        public void write​(byte[] bytes)
        Overrides:
        write in class java.io.OutputStream
      • write

        public void write​(int b)
        Specified by:
        write in class java.io.OutputStream