ap
Class EasyReader

java.lang.Object
  extended byap.EasyReader

public class EasyReader
extends java.lang.Object


Field Summary
protected static int CLOSEERROR
           
protected static int EOF
           
protected  int myErrorFlags
           
protected  java.lang.String myFileName
           
protected  java.io.BufferedReader myInFile
           
protected static int OPENERROR
           
protected static int READERROR
           
 
Constructor Summary
EasyReader()
          Constructor.
EasyReader(java.lang.String fileName)
          Constructor.
 
Method Summary
 boolean bad()
          Checks the status of the file
 void close()
          Closes the file
 boolean eof()
          Checks the EOF status of the file
 char readChar()
          Reads the next character from a file (any character including a space or a newline character).
 double readDouble()
          Reads the next double (without validating its format)
 int readInt()
          Reads the next integer (without validating its format)
 java.lang.String readLine()
          Reads from the current position in the file up to and including the next newline character.
 java.lang.String readWord()
          Skips whitespace and reads the next word (a string of consecutive non-whitespace characters (up to but excluding the next space, newline, etc.)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myFileName

protected java.lang.String myFileName

myInFile

protected java.io.BufferedReader myInFile

myErrorFlags

protected int myErrorFlags

OPENERROR

protected static final int OPENERROR
See Also:
Constant Field Values

CLOSEERROR

protected static final int CLOSEERROR
See Also:
Constant Field Values

READERROR

protected static final int READERROR
See Also:
Constant Field Values

EOF

protected static final int EOF
See Also:
Constant Field Values
Constructor Detail

EasyReader

public EasyReader()
Constructor. Prepares console (System.in) for reading


EasyReader

public EasyReader(java.lang.String fileName)
Constructor. opens a file for reading

Parameters:
fileName - the name or pathname of the file
Method Detail

close

public void close()
Closes the file


bad

public boolean bad()
Checks the status of the file

Returns:
true if en error occurred opening or reading the file, false otherwise

eof

public boolean eof()
Checks the EOF status of the file

Returns:
true if EOF was encountered in the previous read operation, false otherwise

readChar

public char readChar()
Reads the next character from a file (any character including a space or a newline character).

Returns:
character read or null character (Unicode 0) if trying to read beyond the EOF

readLine

public java.lang.String readLine()
Reads from the current position in the file up to and including the next newline character. The newline character is thrown away

Returns:
the read string (excluding the newline character) or null if trying to read beyond the EOF

readWord

public java.lang.String readWord()
Skips whitespace and reads the next word (a string of consecutive non-whitespace characters (up to but excluding the next space, newline, etc.)

Returns:
the read string or null if trying to read beyond the EOF

readInt

public int readInt()
Reads the next integer (without validating its format)

Returns:
the integer read or 0 if trying to read beyond the EOF

readDouble

public double readDouble()
Reads the next double (without validating its format)

Returns:
the number read or 0 if trying to read beyond the EOF