Class FileSetInputStream

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

    public class FileSetInputStream
    extends java.io.InputStream
    Class that collapses a set of files into one input stream. All files matching a given pattern are collected, parts of the file name contains part of the data, and the values in the file name are appended (or prepended) to each data line.
    Author:
    Mario Frasca
    • Constructor Summary

      Constructors 
      Constructor Description
      FileSetInputStream​(java.lang.String dirName, java.lang.String fileNamePattern, java.lang.String[] fieldsInName, java.lang.String separator, boolean prepend, boolean headerless, CryptoFilter filter, int skipLeadingDataLines)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      int read()
      Reads the next byte of data from the input stream.
      void reset()  
      • Methods inherited from class java.io.InputStream

        available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, skip, transferTo
      • Methods inherited from class java.lang.Object

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

      • FileSetInputStream

        public FileSetInputStream​(java.lang.String dirName,
                                  java.lang.String fileNamePattern,
                                  java.lang.String[] fieldsInName,
                                  java.lang.String separator,
                                  boolean prepend,
                                  boolean headerless,
                                  CryptoFilter filter,
                                  int skipLeadingDataLines)
                           throws java.io.IOException
        Parameters:
        dirName - the containing directory
        fileNamePattern - the regular expression describing the file name and the extra fields.
        fieldsInName - the names of the fields contained in the file name.
        separator - the separator to use when faking output (typically the ",").
        prepend - whether the extra fields should precede the ones from the file content.
        headerless - if true, then there is no header on first line of file.
        filter - filter for decoding bytes read from file.
        skipLeadingDataLines - number of lines to skip at start of file before header line.
        Throws:
        java.io.IOException - if a file cannot be opened or read.
    • Method Detail

      • 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.InputStream
        Throws:
        java.io.IOException
      • read

        public int read()
                 throws java.io.IOException
        Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. if the end of the current source file is reached, the next single file is opened. if all input has been used, -1 is returned. to output the tail, we just glue it before each '\n' to output the lead, we have to look ahead and append it to all '\n' that are not followed by '\n' or -1
        Specified by:
        read in class java.io.InputStream
        Returns:
        the next byte of data, or -1 if the end of the stream is reached.
        Throws:
        java.io.IOException - if an I/O error occurs.
      • reset

        public void reset()
                   throws java.io.IOException
        Overrides:
        reset in class java.io.InputStream
        Throws:
        java.io.IOException