Class OutputLogger.OutputPrintStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable
    Enclosing class:
    OutputLogger

    public static class OutputLogger.OutputPrintStream
    extends java.io.PrintStream
    A print stream class to capture all data from stdout and stderr.
    Version:
    $Revision: 15092 $
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Summary

      Constructors 
      Constructor Description
      OutputPrintStream​(OutputLogger owner, java.io.PrintStream stream)
      Default constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.PrintStream append​(char c)
      Appends the specified character to this output stream.
      java.io.PrintStream append​(java.lang.CharSequence csq)
      Appends the specified character sequence to this output stream.
      java.io.PrintStream append​(java.lang.CharSequence csq, int start, int end)
      Appends a subsequence of the specified character sequence to this output stream.
      void flush()
      ignored.
      void print​(boolean x)
      prints the given boolean to the streams.
      void print​(int x)
      prints the given int to the streams.
      void print​(java.lang.Object x)
      prints the given object to the streams.
      void print​(java.lang.String x)
      prints the given string to the streams.
      void println()
      prints a new line to the streams.
      void println​(boolean x)
      prints the given boolean to the streams.
      void println​(int x)
      prints the given int to the streams.
      void println​(java.lang.Object x)
      prints the given object to the streams (for Throwables we print the stack trace).
      void println​(java.lang.String x)
      prints the given string to the streams.
      void write​(byte[] b)
      Writes the bytes to the stream.
      void write​(byte[] buf, int off, int len)
      Writes the bytes to the stream.
      void write​(int b)
      Writes the byte to the stream.
      • Methods inherited from class java.io.PrintStream

        checkError, close, format, format, print, print, print, print, print, printf, printf, println, println, println, println, println
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • OutputPrintStream

        public OutputPrintStream​(OutputLogger owner,
                                 java.io.PrintStream stream)
                          throws java.lang.Exception
        Default constructor.
        Parameters:
        owner - the owning logger
        stream - the stream
        Throws:
        java.lang.Exception - if something goes wrong
    • Method Detail

      • flush

        public void flush()
        ignored.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.PrintStream
      • print

        public void print​(int x)
        prints the given int to the streams.
        Overrides:
        print in class java.io.PrintStream
        Parameters:
        x - the object to print
      • print

        public void print​(boolean x)
        prints the given boolean to the streams.
        Overrides:
        print in class java.io.PrintStream
        Parameters:
        x - the object to print
      • print

        public void print​(java.lang.String x)
        prints the given string to the streams.
        Overrides:
        print in class java.io.PrintStream
        Parameters:
        x - the object to print
      • print

        public void print​(java.lang.Object x)
        prints the given object to the streams.
        Overrides:
        print in class java.io.PrintStream
        Parameters:
        x - the object to print
      • println

        public void println()
        prints a new line to the streams.
        Overrides:
        println in class java.io.PrintStream
      • println

        public void println​(int x)
        prints the given int to the streams.
        Overrides:
        println in class java.io.PrintStream
        Parameters:
        x - the object to print
      • println

        public void println​(boolean x)
        prints the given boolean to the streams.
        Overrides:
        println in class java.io.PrintStream
        Parameters:
        x - the object to print
      • println

        public void println​(java.lang.String x)
        prints the given string to the streams.
        Overrides:
        println in class java.io.PrintStream
        Parameters:
        x - the object to print
      • println

        public void println​(java.lang.Object x)
        prints the given object to the streams (for Throwables we print the stack trace).
        Overrides:
        println in class java.io.PrintStream
        Parameters:
        x - the object to print
      • write

        public void write​(int b)
        Writes the byte to the stream.
        Overrides:
        write in class java.io.PrintStream
        Parameters:
        b - the byte to write
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Writes the bytes to the stream.
        Overrides:
        write in class java.io.FilterOutputStream
        Parameters:
        b - the bytes to write
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] buf,
                          int off,
                          int len)
        Writes the bytes to the stream.
        Overrides:
        write in class java.io.PrintStream
        Parameters:
        buf - the buffer to use
        off - the offset
        len - the number of bytes to write
      • append

        public java.io.PrintStream append​(java.lang.CharSequence csq,
                                          int start,
                                          int end)
        Appends a subsequence of the specified character sequence to this output stream.

        An invocation of this method of the form out.append(csq, start, end) when csq is not null, behaves in exactly the same way as the invocation

        
             out.print(csq.subSequence(start, end).toString())
         
        Specified by:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.io.PrintStream
        Parameters:
        csq - The character sequence from which a subsequence will be appended. If csq is null, then characters will be appended as if csq contained the four characters "null".
        start - The index of the first character in the subsequence
        end - The index of the character following the last character in the subsequence
        Returns:
        This output stream
        Throws:
        java.lang.IndexOutOfBoundsException - If start or end are negative, start is greater than end, or end is greater than csq.length()
        Since:
        1.5
      • append

        public java.io.PrintStream append​(java.lang.CharSequence csq)
        Appends the specified character sequence to this output stream.

        An invocation of this method of the form out.append(csq) behaves in exactly the same way as the invocation

        
             out.print(csq.toString())
         

        Depending on the specification of toString for the character sequence csq, the entire sequence may not be appended. For instance, invoking then toString method of a character buffer will return a subsequence whose content depends upon the buffer's position and limit.

        Specified by:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.io.PrintStream
        Parameters:
        csq - The character sequence to append. If csq is null, then the four characters "null" are appended to this output stream.
        Returns:
        This output stream
        Since:
        1.5
      • append

        public java.io.PrintStream append​(char c)
        Appends the specified character to this output stream.

        An invocation of this method of the form out.append(c) behaves in exactly the same way as the invocation

        
             out.print(c)
         
        Specified by:
        append in interface java.lang.Appendable
        Overrides:
        append in class java.io.PrintStream
        Parameters:
        c - The 16-bit character to append
        Returns:
        This output stream
        Since:
        1.5