com.meyling.principia.io
Class TextFileReader

java.lang.Object
  |
  +--com.meyling.principia.io.TextFileReader
Direct Known Subclasses:
PackageTest.TestReader, PackageTest.TestReader

public class TextFileReader
extends Object

Wrapper for the class FileReader.

Version:
$Revision 0.00.50$
Author:
Michael Meyling

Field Summary
private  boolean alreadyRead
          is there a row in the read buffer?
private  BufferedReader in
          file to read from
private  String inFileName
          file name
private  String line
          last read line
private  int lineNumber
          line counter
 
Constructor Summary
TextFileReader(String inputName)
          Creates a TextFileReader object.
 
Method Summary
 void close()
          Closes input.
 String getInFileName()
          Get name of input file.
 String getLine()
          Get currently read line.
 int getLineNumber()
          Get currently read line number.
 String readLine()
          For simple reading a complete line of the input file.
 void unReadLine()
          Undos the readLine() method.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

in

private BufferedReader in
file to read from

inFileName

private String inFileName
file name

lineNumber

private int lineNumber
line counter

line

private String line
last read line

alreadyRead

private boolean alreadyRead
is there a row in the read buffer? Is used to undo the reading of a singular line.
Constructor Detail

TextFileReader

public TextFileReader(String inputName)
               throws IOException
Creates a TextFileReader object.
Parameters:
inputName - name of the input file
Throws:
IOException - if the buffered reader couldn't be created
Method Detail

close

public void close()
Closes input.

readLine

public String readLine()
                throws IOException
For simple reading a complete line of the input file. The line is stored in the class attribut line Comments are ignored
Returns:
eingelesene Zeile
Throws:
IOException - wenn ein Lesefehler auftrat

unReadLine

public void unReadLine()
                throws IllegalStateException
Undos the readLine() method. Only one readLine() call can be cancelled. Further calls lead to an IllegalStateException. A following readLine() call gives the last result again.
Throws:
IllegalStateException - if undo isn't allowed any more

getLine

public String getLine()
Get currently read line.
Returns:
currently read line

getLineNumber

public int getLineNumber()
Get currently read line number.
Returns:
currently read line number

getInFileName

public String getInFileName()
Get name of input file.
Returns:
name of input file