org.pz.platypus
Class TextFileReader

java.lang.Object
  extended by org.pz.platypus.TextFileReader

public class TextFileReader
extends java.lang.Object

Reads files consisting of lines of text, one line at a time. All standard I/O handled here. Used for reading config and resource files.

Author:
alb

Field Summary
private  java.lang.String filename
           
private  java.io.BufferedReader reader
           
private  boolean trimWhitespace
           
 
Constructor Summary
TextFileReader(java.lang.String fileName)
          Create an instance of org.pz.platypus.TextFileReader to read the specified file
 
Method Summary
 void open()
          opens the reader for the indicated file
 java.lang.String retrieveNextLine()
          Reads a line, optionally trims trailing whitespace, and returns it
 void setTrimWhiteSpace(boolean yesNo)
          Set whether the reader should trim whitespace on lines read in
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filename

private java.lang.String filename

reader

private java.io.BufferedReader reader

trimWhitespace

private boolean trimWhitespace
Constructor Detail

TextFileReader

public TextFileReader(java.lang.String fileName)
Create an instance of org.pz.platypus.TextFileReader to read the specified file

Parameters:
fileName - name of the file to read
Throws:
java.lang.IllegalArgumentException - if filename is null
Method Detail

open

public void open()
          throws java.io.FileNotFoundException
opens the reader for the indicated file

Throws:
java.io.FileNotFoundException - if the file specified by filename does not exist.

retrieveNextLine

public java.lang.String retrieveNextLine()
                                  throws java.io.IOException
Reads a line, optionally trims trailing whitespace, and returns it

Returns:
the line of text. Null at EOF.
Throws:
java.io.IOException - if an error occurs reading the file

setTrimWhiteSpace

public void setTrimWhiteSpace(boolean yesNo)
Set whether the reader should trim whitespace on lines read in

Parameters:
yesNo -


Copyright © 2008-10 Pacific Data Works LLC