Class MultipleFilesOutput

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

    public class MultipleFilesOutput
    extends java.lang.Object
    implements StreamFactory
    Manage output to multiple files.
    Since:
    0.2
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.nio.file.Path basename
      Base file name.
      private static java.lang.String EXTENSION
      File name extension.
      private static java.lang.String GZIP_EXTENSION
      GZip extra file extension
      private static Logging LOG
      Logger for debugging.
      private boolean usegzip
      Control gzip compression of output.
    • Constructor Summary

      Constructors 
      Constructor Description
      MultipleFilesOutput​(java.nio.file.Path base)
      Constructor
      MultipleFilesOutput​(java.nio.file.Path base, boolean gzip)
      Constructor
    • 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!)
      private java.io.PrintStream newStream​(java.lang.String name)
      Open a new stream of the given name
      java.io.PrintStream openStream​(java.lang.String filename)
      Retrieve the output stream for the given file name.
      • Methods inherited from class java.lang.Object

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

      • EXTENSION

        private static final java.lang.String EXTENSION
        File name extension.
        See Also:
        Constant Field Values
      • GZIP_EXTENSION

        private static final java.lang.String GZIP_EXTENSION
        GZip extra file extension
        See Also:
        Constant Field Values
      • basename

        private java.nio.file.Path basename
        Base file name.
      • usegzip

        private boolean usegzip
        Control gzip compression of output.
      • LOG

        private static final Logging LOG
        Logger for debugging.
    • Constructor Detail

      • MultipleFilesOutput

        public MultipleFilesOutput​(java.nio.file.Path base)
        Constructor
        Parameters:
        base - Base file name (folder name)
      • MultipleFilesOutput

        public MultipleFilesOutput​(java.nio.file.Path base,
                                   boolean gzip)
        Constructor
        Parameters:
        base - Base file name (folder name)
        gzip - Use gzip compression.
    • Method Detail

      • newStream

        private java.io.PrintStream newStream​(java.lang.String name)
                                       throws java.io.IOException
        Open a new stream of the given name
        Parameters:
        name - file name (which will be appended to the base name)
        Returns:
        stream object for the given name
        Throws:
        java.io.IOException
      • openStream

        public java.io.PrintStream openStream​(java.lang.String filename)
                                       throws java.io.IOException
        Retrieve the output stream for the given file name.
        Specified by:
        openStream in interface StreamFactory
        Parameters:
        filename - Output label.
        Returns:
        stream object for the given label
        Throws:
        java.io.IOException - on IO error
      • 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