Package org.relique.io
Class FileSetInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.relique.io.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()
-
-
-
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 directoryfileNamePattern
- 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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.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 classjava.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 classjava.io.InputStream
- Throws:
java.io.IOException
-
-