Class Console

java.lang.Object
   |
   +----Console

public class Console
extends java.lang.Object
An easy interface to read numbers and strings from standard input


Constructor Index

 o Console()

Method Index

 o printPrompt(String)
print a prompt on the console but don't print a newline
 o readDouble(String)
read a floating point number from the console.
 o readInt(String)
read an integer from the console.
 o readString()
read a string from the console.
 o readString(String)
read a string from the console.
 o readWord()
read a word from the console.

Constructors

 o Console
 public Console()

Methods

 o printPrompt
 public static void printPrompt(java.lang.String prompt)
print a prompt on the console but don't print a newline

Parameters:
prompt - the prompt string to display
 o readString
 public static java.lang.String readString()
read a string from the console. The string is terminated by a newline

Returns:
the input string (without the newline)
 o readString
 public static java.lang.String readString(java.lang.String prompt)
read a string from the console. The string is terminated by a newline

Parameters:
prompt - the prompt string to display
Returns:
the input string (without the newline)
 o readWord
 public static java.lang.String readWord()
read a word from the console. The word is any set of characters terminated by whitespace

Returns:
the 'word' entered
 o readInt
 public static int readInt(java.lang.String prompt)
read an integer from the console. The input is terminated by a newline

Parameters:
prompt - the prompt string to display
Returns:
the input value as an int
Throws: NumberFormatException
if bad input
 o readDouble
 public static double readDouble(java.lang.String prompt)
read a floating point number from the console. The input is terminated by a newline

Parameters:
prompt - the prompt string to display
Returns:
the input value as a double
Throws: NumberFormatException
if bad input