BreezyGUI
Class Console
java.lang.Object
|
+--BreezyGUI.Console
- public class Console
- extends java.lang.Object
The class Console contains methods for terminal I/O. Type-specific
methods read characters, integers, doubles, and strings. Another
method pauses output and waits for the user to hit the enter key
to continue. Examples:
char letter = Console.readChar("Enter a letter: ");
double d = Console.readDouble("Enter a real number: ");
int i = Console.readInt("Enter an integer: ");
String name = Console.readLine("Enter your full name: ");
Console.pause();
Method Summary |
static void |
pause()
Used with non-GUI applications (tester programs) to pause execution
until the user hits the Enter key. |
static char |
readChar(java.lang.String prompt)
Prompts the user and waits for character input. |
static double |
readDouble(java.lang.String prompt)
Prompts the user and waits for double input. |
static int |
readInt(java.lang.String prompt)
Prompts the user and waits for integer input. |
static 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 |
Console
public Console()
pause
public static void pause()
- Used with non-GUI applications (tester programs) to pause execution
until the user hits the Enter key.
Prevents a "fly-by" disappearance of the terminal window
in some environments by pausing execution until the user
hits the Enter key. Usage: Console.pause();
readInt
public static int readInt(java.lang.String prompt)
- Prompts the user and waits for integer input. Throws a NumberFormatException
if the input cannot represent an integer. Returns the integer entered.
- Parameters:
prompt
- the prompt to the user.
readDouble
public static double readDouble(java.lang.String prompt)
- Prompts the user and waits for double input. Throws a NumberFormatException
if the input cannot represent a double. Returns the double entered.
- Parameters:
prompt
- the prompt to the user.
readChar
public static char readChar(java.lang.String prompt)
- Prompts the user and waits for character input. Returns the char entered.
- Parameters:
prompt
- the prompt to the user.
readLine
public static java.lang.String readLine(java.lang.String prompt)
- Prompts the user and waits for string input. Returns the entire line
of text entered.
- Parameters:
prompt
- the prompt to the user.