com.isti.util
Class FileProcessor

java.lang.Object
  extended by com.isti.util.FileProcessor

public class FileProcessor
extends java.lang.Object

Class FileProcessor helper class for processing a text input file into a text output file.


Field Summary
 java.io.BufferedReader inputReaderObj
          Reader object for input file.
 java.io.PrintWriter outputWriterObj
          Writer object for output file.
 
Constructor Summary
FileProcessor(java.lang.String inFName, java.lang.String outFName)
          Creates a file processor object and opens input and output files.
 
Method Summary
 void closeInputFile()
          Closes the input file.
 void closeOutputFile()
          Closes the output file.
 java.lang.String readNextLine()
          Reads and returns the next line of data from the input file.
 void writeNextLine(java.lang.String str)
          Writes the given line of data to the output file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputReaderObj

public java.io.BufferedReader inputReaderObj
Reader object for input file.


outputWriterObj

public java.io.PrintWriter outputWriterObj
Writer object for output file.

Constructor Detail

FileProcessor

public FileProcessor(java.lang.String inFName,
                     java.lang.String outFName)
              throws java.io.FileNotFoundException,
                     java.io.IOException
Creates a file processor object and opens input and output files.

Parameters:
inFName - name of input text file to use.
outFName - name of output text file to use.
Throws:
java.io.FileNotFoundException - if the input file is not found.
java.io.IOException - if an I/O error occurs.
Method Detail

readNextLine

public java.lang.String readNextLine()
                              throws java.io.IOException
Reads and returns the next line of data from the input file. When the end of the input file is reached, the input and output files are closed and 'null' is returned.

Returns:
A string containing a line of data from the input file, or null if the end of the input file has been reached.
Throws:
java.io.IOException - if an I/O error occurs.

writeNextLine

public void writeNextLine(java.lang.String str)
                   throws java.io.IOException
Writes the given line of data to the output file. A line-end is appended to the data written to the file.

Parameters:
str - a string containing the line of data to be written.
Throws:
java.io.IOException - if an I/O error occurs.

closeInputFile

public void closeInputFile()
Closes the input file. This method does not usually need to be called because the 'readNextLine()' method closes the input and output file after it reaches the end of the input file.


closeOutputFile

public void closeOutputFile()
Closes the output file. This method does not usually need to be called because the 'readNextLine()' method closes the input and output file after it reaches the end of the input file.