chn.util
Class SimpleIO
java.lang.Object
|
+--chn.util.SimpleIO
- Direct Known Subclasses:
- ConsoleIO, FileInput
- public class SimpleIO
- extends java.lang.Object
|
Field Summary |
protected java.lang.String |
delimiters
|
protected java.io.BufferedReader |
in
|
protected java.util.StringTokenizer |
tokens
|
|
Constructor Summary |
SimpleIO()
Constructs the SimpleIO object with default delimiters, space,
tab, formfeed. |
SimpleIO(java.lang.String delims)
Constructs the ConsoleIO object with given delimiters. |
|
Method Summary |
boolean |
readBoolean()
Reads and returns the next boolean from the current line. |
double |
readDouble()
Reads and returns the next double from the current line. |
int |
readInt()
Reads and returns the next integer from the current line. |
java.lang.String |
readLine()
Flushes any remaining tokens on the current input line, then reads the
next full line input as a String and returns it. |
java.lang.String |
readToken()
Reads and returns the next token from the current line. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
in
protected java.io.BufferedReader in
tokens
protected java.util.StringTokenizer tokens
delimiters
protected java.lang.String delimiters
SimpleIO
public SimpleIO()
- Constructs the SimpleIO object with default delimiters, space,
tab, formfeed. Newline and return characters terminate the input
of the current line.
SimpleIO
public SimpleIO(java.lang.String delims)
- Constructs the ConsoleIO object with given delimiters.
Newline and return characters terminate the input of the current line.
readToken
public java.lang.String readToken()
- Reads and returns the next token from the current line. A token is a
String of characters separated by the specified delimiters. If the current
input line has no more unread tokens, reads the first token from the first
non-empty line entered.
- Returns:
- the next String token from input, as determined by delimiters
readInt
public int readInt()
- Reads and returns the next integer from the current line. If the current
input line has no more unread tokens, reads the first token from the first
non-empty line entered.
If the next token is not the correct format for an integer, then a error
message is printed and the program terminates.
- Returns:
- next integer from input
readDouble
public double readDouble()
- Reads and returns the next double from the current line. If the current
input line has no more unread tokens, reads the first token from the first
non-empty line entered.
If the next token is not the correct format for a double, then a error
message is printed and the program terminates.
- Returns:
- the next double from input
readBoolean
public boolean readBoolean()
- Reads and returns the next boolean from the current line. If the current
input line has no more unread tokens, reads the first token from the first
non-empty line entered.
A valid boolean is any token. The value true is returned if the token is
"true", with upper or lower case letters, otherwise false is returned.
- Returns:
- the next boolean from input
readLine
public java.lang.String readLine()
- Flushes any remaining tokens on the current input line, then reads the
next full line input as a String and returns it.
- Returns:
- next line read as a String