Class TextFileReader

java.lang.Object
  |
  +--TextFileReader

public class TextFileReader
extends Object

The TextFileReader class is an actor class which reads input from a specified file one sentence at a time. Sentences are assumed to be terminated with one of the following characters: '.', ':', ';', '?' or '!'.

To read input from a file named TestInput.txt, create a TextFileReader as follows:

Once a TextFileReader has been created, each call to the nextSentence method returns a new Sentence object containing the next sentence from the input file. Once all sentences have been read, the nextSentence method returns null. Thus, the following code would read every sentence in the TestInput.txt file:


Constructor Summary
TextFileReader(String filename)
          Construct a new TextFileReader to be used to read sentences from the specified file.
 
Method Summary
 Sentence nextSentence()
          Get the next Sentence from the file associated with this TextFileReader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextFileReader

public TextFileReader(String filename)
Construct a new TextFileReader to be used to read sentences from the specified file.

Parameters:
filename - the filename of the file from which to read sentences.
Method Detail

nextSentence

public Sentence nextSentence()
Get the next Sentence from the file associated with this TextFileReader. If the end of the file has been reached and there are no more sentences this method will return null.

Returns:
the next Sentence in the input file, or null if the end of file has been reached.