|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--TerminalIO.KeyboardReader
The class KeyboardReader contains input methods for terminal I/O. Type-specific methods read characters, integers, doubles, and strings. Another method pauses output and waits for the user to press the enter key to continue. Examples:
KeyboardReader reader = new KeyboardReader(); char letter = reader.readChar ("Enter a letter: "); double d = reader.readDouble("Enter a real number: "); int i = reader.readInt ("Enter an integer: "); String name = reader.readLine ("Enter your full name: "); reader.pause();
Constructor Summary | |
KeyboardReader()
|
Method Summary | |
void |
pause()
Used with non-GUI applications to prevents a "fly-by" disappearance of the terminal window in some environments by pausing execution until the user presses the Enter key. |
char |
readChar()
Waits for character input without prompting the user. |
char |
readChar(java.lang.String prompt)
Prompts the user and waits for character input. |
double |
readDouble()
Waits for double input without prompting the user. |
double |
readDouble(java.lang.String prompt)
Prompts the user and waits for double input. |
int |
readInt()
Waits for integer input without prompting the user. |
int |
readInt(java.lang.String prompt)
Prompts the user and waits for integer input. |
java.lang.String |
readLine()
Waits for string input without prompting the user. |
java.lang.String |
readLine(java.lang.String prompt)
Prompts the user and waits for string input. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public KeyboardReader()
Method Detail |
public void pause()
public int readInt(java.lang.String prompt)
prompt
- the prompt to the user.public int readInt()
public double readDouble(java.lang.String prompt)
prompt
- the prompt to the user.public double readDouble()
public char readChar(java.lang.String prompt)
prompt
- the prompt to the user.public char readChar()
public java.lang.String readLine(java.lang.String prompt)
prompt
- the prompt to the user.public java.lang.String readLine()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |