Class SingleStreamOutput

  • All Implemented Interfaces:
    StreamFactory, java.lang.AutoCloseable

    public class SingleStreamOutput
    extends java.lang.Object
    implements StreamFactory
    Class to output all result data to a single stream (e.g., Stdout, single file)
    Since:
    0.2
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.PrintStream stream
      Output stream
    • Constructor Summary

      Constructors 
      Constructor Description
      SingleStreamOutput()
      Constructor using stdout.
      SingleStreamOutput​(java.io.OutputStream out)
      Constructor with given FileOutputStream.
      SingleStreamOutput​(java.io.OutputStream out, boolean gzip)
      Constructor with given FileOutputStream.
      SingleStreamOutput​(java.io.PrintStream os)
      Constructor with a print stream.
      SingleStreamOutput​(java.nio.file.Path out)
      Constructor with given file name.
      SingleStreamOutput​(java.nio.file.Path out, boolean gzip)
      Constructor with given file name.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close stream factory.
      void closeStream​(java.io.PrintStream stream)
      Close the given output stream (Note: when writing to a single stream output, it will actually not be closed!)
      java.io.PrintStream openStream​(java.lang.String filename)
      Return the objects shared print stream.
      • Methods inherited from class java.lang.Object

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

      • stream

        private java.io.PrintStream stream
        Output stream
    • Constructor Detail

      • SingleStreamOutput

        public SingleStreamOutput()
                           throws java.io.IOException
        Constructor using stdout.
        Throws:
        java.io.IOException - on IO error
      • SingleStreamOutput

        public SingleStreamOutput​(java.nio.file.Path out)
                           throws java.io.IOException
        Constructor with given file name.
        Parameters:
        out - filename
        Throws:
        java.io.IOException - on IO error
      • SingleStreamOutput

        public SingleStreamOutput​(java.nio.file.Path out,
                                  boolean gzip)
                           throws java.io.IOException
        Constructor with given file name.
        Parameters:
        out - filename
        gzip - Use gzip compression
        Throws:
        java.io.IOException - on IO error
      • SingleStreamOutput

        public SingleStreamOutput​(java.io.OutputStream out)
                           throws java.io.IOException
        Constructor with given FileOutputStream.
        Parameters:
        out - File output stream
        Throws:
        java.io.IOException - on IO error
      • SingleStreamOutput

        public SingleStreamOutput​(java.io.OutputStream out,
                                  boolean gzip)
                           throws java.io.IOException
        Constructor with given FileOutputStream.
        Parameters:
        out - File output stream
        gzip - Use gzip compression
        Throws:
        java.io.IOException - on IO error
      • SingleStreamOutput

        public SingleStreamOutput​(java.io.PrintStream os)
        Constructor with a print stream.
        Parameters:
        os - Output stream
    • Method Detail

      • openStream

        public java.io.PrintStream openStream​(java.lang.String filename)
        Return the objects shared print stream.
        Specified by:
        openStream in interface StreamFactory
        Parameters:
        filename - ignored filename for SingleStreamOutput, as the name suggests
        Returns:
        stream object for the given label
      • closeStream

        public void closeStream​(java.io.PrintStream stream)
        Description copied from interface: StreamFactory
        Close the given output stream (Note: when writing to a single stream output, it will actually not be closed!)
        Specified by:
        closeStream in interface StreamFactory
        Parameters:
        stream - Stream to close
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: StreamFactory
        Close stream factory.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface StreamFactory
        Throws:
        java.io.IOException