org.relique.io
Class FileSetInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.relique.io.FileSetInputStream
All Implemented Interfaces:
Closeable

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 Summary
FileSetInputStream(String dirName, String fileNamePattern, String[] fieldsInName, String separator, boolean prepend, boolean headerless, CryptoFilter filter, int skipLeadingDataLines)
           
 
Method Summary
 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, read, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSetInputStream

public FileSetInputStream(String dirName,
                          String fileNamePattern,
                          String[] fieldsInName,
                          String separator,
                          boolean prepend,
                          boolean headerless,
                          CryptoFilter filter,
                          int skipLeadingDataLines)
                   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

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

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.

reset

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


Copyright © 2016. All rights reserved.