|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jmonks.batch.io.FileReader
FileReader reads the specified file based on the given file spec and returns the data in the form of ReaderRecord's to read the required values referring the field names. This provides the methods to reads the records in an iterative manner. Once finished reading all or required records from the file reader, it should be closed by calling the appropriate methods. This provides the factory method to create the file reader based on the file spec. Here is a sample code snippet to use the file reader.
InputStream fileSpecInputStream=...; InputStream fileInputStream=....; FileReader fileReader=FileReader.getFileReader(fileInputStream,fileSpecInputStream); ReaderRecord record=null; while((record=fileReader.getNextRecord())!=null) { if(record.getRecordType()==RecordType.DETAIL) { String consumerID=record.readField("consumer-id"); // Read the rest of the fields and does the processing. } } fileReader.close();
Constructor Summary | |
FileReader()
|
Method Summary | |
abstract void |
close()
Closes the reader and releases all the resources associated with the reader. |
static FileReader |
getFileReader(java.io.InputStream fileInputStream,
FileSpec fileSpec)
Factory method to get the file reader. |
static FileReader |
getFileReader(java.io.InputStream fileInputStream,
java.io.InputStream fileSpecInputStream)
Factory method to get the file reader. |
static FileReader |
getFileReader(java.io.Reader reader,
FileSpec fileSpec)
Factory method to get the file reader. |
static FileReader |
getFileReader(java.io.Reader reader,
java.io.InputStream fileSpecInputStream)
Factory method to get the file reader. |
abstract ReaderRecord |
getNextRecord()
Gets the next available record from the file. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileReader()
Method Detail |
public abstract ReaderRecord getNextRecord()
Gets the next available record from the file. If file doesnt have any more records it returns null.
FileParseException
- Problems while parsing the next record.public abstract void close()
public static FileReader getFileReader(java.io.InputStream fileInputStream, java.io.InputStream fileSpecInputStream)
Factory method to get the file reader. This method returns the appropriate file reader based on the file type specified in the file spec.
fileInputStream
- Input stream to read the data file.fileSpecInputStream
- Input stream to read the file spec.
java.lang.IllegalArgumentException
- If the given fileInputStream or fileSpecInputStream is null.
FileSpecException
- If the configured file type in file spec doesnt
exist in FileType class.public static FileReader getFileReader(java.io.InputStream fileInputStream, FileSpec fileSpec)
Factory method to get the file reader. This method returns the appropriate file reader based on the file type specified in the file spec.
fileInputStream
- Input stream to read the data file.fileSpec
- File spec to create the file reader.
java.lang.IllegalArgumentException
- If the given fileInputStream or fileSpec is null.
FileSpecException
- If the configured file type in file spec doesnt
exist in FileType class.public static FileReader getFileReader(java.io.Reader reader, java.io.InputStream fileSpecInputStream)
Factory method to get the file reader. This method returns the appropriate file reader based on the file type specified in the file spec.
reader
- Reader to read the data file.fileSpecInputStream
- Input stream to read the file spec.
java.lang.IllegalArgumentException
- If the given reader or fileSpecInputStream is null.
FileSpecException
- If the configured file type in file spec doesnt
exist in FileType class.public static FileReader getFileReader(java.io.Reader reader, FileSpec fileSpec)
Factory method to get the file reader. This method returns the appropriate file reader based on the file type specified in the file spec.
reader
- Reader to read the data file.fileSpec
- File spec to create the file reader.
java.lang.IllegalArgumentException
- If the given reader or fileSpec is null.
FileSpecException
- If the configured file type in file spec doesnt
exist in FileType class.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |