ConsoleIO
CLASS SPECIFICATIONS
These
classes are not part of Java but are available through the library named chn.util. You must have the file chnutil.jar in the appropriate directory
where Java can access it. To have these
classes available in your program, use this command:
import
chn.util.*;
Other
features of chn.util will be covered in later
lessons.
ConsoleIO |
protected String
delimeters protected
java.io.BufferedReader in protected
java.util.StringTokenizer tokesn |
<<constructors>> ConsoleIO() ConsoleIO(String
delims) <<accessors>> public
boolean readBoolean() public
double readDouble() public
int readInt() public
String readLine() public
String readToken() <<modifiers>> ... |
public
ConsoleIO()
postcondition
Constructs the ConsoleIO object with default
delimiters, space, tab, formfeed.
public ConsoleIO
(String delims)
postcondition
Constructs the ConsoleIO object with given
delimiters.
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.
postcondition
returns the next boolean from input.
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.
postcondition
returns the next double from input.
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.
postcondition
returns the next integer from input.
public String readLine()
Flushes any remaining tokens on the current input line, then reads the
next full line input as a String and returns it.
postcondition
returns the next line read as a String.
public 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.
postcondition
returns the next String token from input, as
determined by delimiters
.