Class IOConsoleOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
    Direct Known Subclasses:
    MessageConsoleStream

    public class IOConsoleOutputStream
    extends java.io.OutputStream
    OutputStream used to write to an IOConsole.

    Clients are not intended to instantiate this class directly, instead use IOConsole.newOutputStream().

    Clients should avoid writing large amounts of output to this stream in the UI thread. The console needs to process the output in the UI thread and if the client hogs the UI thread writing output to the console, the console will not be able to process the output.

    Since:
    3.1
    Restriction:
    This class is not intended to be subclassed by clients.
    Restriction:
    This class is not intended to be instantiated by clients.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void flush()  
      Color getColor()
      Returns the color of this stream, or null if default.
      int getFontStyle()
      Returns the font style used to decorate data written to this stream.
      boolean isActivateOnWrite()
      Returns whether the console this stream is writing to will be activated when this stream is written to.
      boolean isClosed()
      Returns true if the stream has been closed
      void setActivateOnWrite​(boolean activateOnWrite)
      Sets whether to activate the console this stream is writing to when this stream is written to.
      void setCharset​(java.nio.charset.Charset charset)  
      void setColor​(Color newColor)
      Sets the color of this stream.
      void setEncoding​(java.lang.String encoding)
      Sets the character encoding used to interpret characters written to this steam.
      void setFontStyle​(int newFontStyle)
      Sets the font style to be used to decorate data written to this stream.
      void write​(byte[] b)  
      void write​(byte[] b, int off, int len)  
      void write​(char[] buffer)
      Writes a character array to the attached console.
      void write​(char[] buffer, int off, int len)
      Writes a character array using specified offset and length to the attached console.
      void write​(int b)  
      void write​(java.lang.CharSequence chars)
      Writes a character sequence to the attached console.
      void write​(java.lang.String str)
      Writes a string to the attached console.
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

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

      • getFontStyle

        public int getFontStyle()
        Returns the font style used to decorate data written to this stream.
        Returns:
        the font style used to decorate data written to this stream
      • setFontStyle

        public void setFontStyle​(int newFontStyle)
        Sets the font style to be used to decorate data written to this stream.
        Parameters:
        newFontStyle - the font style to be used to decorate data written to this stream
      • isActivateOnWrite

        public boolean isActivateOnWrite()
        Returns whether the console this stream is writing to will be activated when this stream is written to.
        Returns:
        whether the console this stream is writing to will be activated when this stream is written to.
      • setActivateOnWrite

        public void setActivateOnWrite​(boolean activateOnWrite)
        Sets whether to activate the console this stream is writing to when this stream is written to.
        Parameters:
        activateOnWrite - whether the console this stream is writing to will be activated when this stream is written to.
      • setColor

        public void setColor​(Color newColor)
        Sets the color of this stream. Use null to indicate the default color.
        Parameters:
        newColor - color of this stream, or null
      • getColor

        public Color getColor()
        Returns the color of this stream, or null if default.
        Returns:
        the color of this stream, or null
      • isClosed

        public boolean isClosed()
        Returns true if the stream has been closed
        Returns:
        true is the stream has been closed, false otherwise.
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

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

        public void write​(char[] buffer)
                   throws java.io.IOException
        Writes a character array to the attached console.
        Parameters:
        buffer - the char array to write to the attached console
        Throws:
        java.io.IOException - if the stream is closed
        Since:
        3.7
      • write

        public void write​(char[] buffer,
                          int off,
                          int len)
                   throws java.io.IOException
        Writes a character array using specified offset and length to the attached console.
        Parameters:
        buffer - the char array to write to the attached console.
        off - the initial offset
        len - the length
        Throws:
        java.io.IOException - if the stream is closed
        Since:
        3.7
      • write

        public void write​(java.lang.CharSequence chars)
                   throws java.io.IOException
        Writes a character sequence to the attached console.
        Parameters:
        chars - the string/characters to write to the attached console.
        Throws:
        java.io.IOException - if the stream is closed.
        Since:
        3.7
      • write

        public void write​(java.lang.String str)
                   throws java.io.IOException
        Writes a string to the attached console.
        Parameters:
        str - the string to write to the attached console
        Throws:
        java.io.IOException - if the stream is closed
      • setEncoding

        public void setEncoding​(java.lang.String encoding)
        Sets the character encoding used to interpret characters written to this steam.
        Parameters:
        encoding - encoding identifier
      • setCharset

        public void setCharset​(java.nio.charset.Charset charset)
                        throws java.io.IOException
        Parameters:
        charset - set the Charset for the attached console
        Throws:
        java.io.IOException - if the stream is closed
        Since:
        3.7