Class FileSetInputStream

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class FileSetInputStream
    extends 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 Detail

      • FileSetInputStream

        public FileSetInputStream​(String dirName,
                                  String fileNamePattern,
                                  String[] fieldsInName,
                                  String separator,
                                  boolean prepend,
                                  boolean headerless,
                                  CryptoFilter filter,
                                  int skipLeadingDataLines,
                                  String charset)
                           throws 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:
        IOException - if a file cannot be opened or read.
    • Method Detail

      • read

        public int read()
                 throws 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 InputStream
        Returns:
        the next byte of data, or -1 if the end of the stream is reached.
        Throws:
        IOException - if an I/O error occurs.