easyIO
Class SimpleIO

java.lang.Object
  |
  +--easyIO.SimpleIO

public class SimpleIO
extends java.lang.Object

This class provides four utility functions to simulate reading integer, single characters and alphabetic Strings. To do this yoiu need to read an entire line into a single string object, and then read integers, alphabetic strings and characters from this String.

See Also:
Java ource code

Constructor Summary
SimpleIO()
           
 
Method Summary
static char getChar(java.lang.String buff)
          This method reads the character at position pos and returns it.
static int getInt(java.lang.String buff)
          This method assumes that starting from position pos the String starts an integer (or white space, i.e space and tab, followed by an integer.
static int getPos()
          This method reads a line of the input file and returns it in a String object
static java.lang.String getWord(java.lang.String buff)
          This method first walks over the white space (blank and tab characters) from position pos and then expects to read a sequence of alphabetical characters, which then it returns
static boolean isEof()
           
static boolean isEoln()
           
static java.lang.String readln()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleIO

public SimpleIO()
Method Detail

getPos

public static int getPos()
This method reads a line of the input file and returns it in a String object
Returns:
a String that contains a line of input
Throws:
IOEException -  

isEof

public static boolean isEof()

isEoln

public static boolean isEoln()

readln

public static java.lang.String readln()
                               throws java.io.IOException,
                                      java.io.EOFException

getInt

public static int getInt(java.lang.String buff)
                  throws EOLNException,
                         NotAnIntegerException
This method assumes that starting from position pos the String starts an integer (or white space, i.e space and tab, followed by an integer.
Returns:
an int which is the value of numeric String just read.
Throws:
EOLNException - when end of line is unexpectedly encountered
NotAnIntegerException - when non-digit character is observed

getChar

public static char getChar(java.lang.String buff)
                    throws EOLNException
This method reads the character at position pos and returns it.
Returns:
an int character.
Throws:
EOLNException - when end of line is encountered unexpectedly

getWord

public static java.lang.String getWord(java.lang.String buff)
                                throws EOLNException
This method first walks over the white space (blank and tab characters) from position pos and then expects to read a sequence of alphabetical characters, which then it returns
Returns:
a String object that will contian the word just read.
Throws:
EOLNException - when endo of line is encountered unexpectedly. it should also throw NotAWordException exception. This should be implemented by the studnet.