Package org.relique.io
Class FileSetInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.relique.io.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 Summary
Constructors Constructor Description FileSetInputStream(String dirName, String fileNamePattern, String[] fieldsInName, String separator, Character quotechar, String quoteStyle, boolean prepend, boolean headerless, CryptoFilter filter, int skipLeadingDataLines, String charset)
-
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
-
-
-
-
Constructor Detail
-
FileSetInputStream
public FileSetInputStream(String dirName, String fileNamePattern, String[] fieldsInName, String separator, Character quotechar, String quoteStyle, boolean prepend, boolean headerless, CryptoFilter filter, int skipLeadingDataLines, String charset) throws 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 ",").quotechar
- the character used to quote column values containing the separator, or null for no quoting.quoteStyle
- either "SQL" or "C" for rule for escaping quote characters in column values.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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- 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 classInputStream
- 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 classInputStream
- Throws:
IOException
-
-