Class EasyReader

java.lang.Object
  extended by EasyReader

public class EasyReader
extends java.lang.Object


Constructor Summary
EasyReader()
          Constructs an EasyReader associated with System.in.
EasyReader(java.lang.String fileName)
          Constructs an EasyReader associated with a file for reading.
 
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 the 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 contiguous string of non-whitespace characters), up to but excluding the next space, newline, etc.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EasyReader

public EasyReader()
Constructs an EasyReader associated with System.in.


EasyReader

public EasyReader(java.lang.String fileName)
Constructs an EasyReader associated with 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 an error occurred when 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 the file (any character including a space or a newline character).

Returns:
the 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 string read (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 contiguous string of non-whitespace characters), up to but excluding the next space, newline, etc.

Returns:
the string read 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, or if the read word does not represent a valid integer.

readDouble

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

Returns:
the number read or Double.NaN, if trying to read beyond the EOF, or if the token read does not represent a valid double.