Class Input
- public class Input
A simple I/O class. Can read ints, doubles, strings, and chars.
Attempts to robustly handle error inputs, by reprompting the user.
Input
public Input()
- Create a new Input object. Defaults to using the
standard input stream.
Input
public Input(java.lang.String fileName)
- Create a new Input object that reads data from the file of
the given name.
newInputFromString
public static Input newInputFromString(java.lang.String s)
- Create and return a new Input object that reads data from the provided
string.
display
protected void display(java.lang.String prompt)
eof
public boolean eof()
readString
public java.lang.String readString(java.lang.String prompt)
- Display the given prompt and read an string.
- Parameters:
prompt
- the prompt to display- Returns:
- the value read
readChar
public char readChar(java.lang.String prompt)
- Display the given prompt and read an char
- Parameters:
prompt
- the prompt to display- Returns:
- the value read
readDouble
public double readDouble(java.lang.String prompt)
- Display the given prompt and read an double.
- Parameters:
prompt
- the prompt to display- Returns:
- the value read
readInt
public int readInt(java.lang.String prompt)
- Display the given prompt and read an int.
- Parameters:
prompt
- the prompt to display- Returns:
- the int read
readString
public java.lang.String readString()
- Read a string without prompting.
- Returns:
- the value read
readChar
public char readChar()
- Read a char without prompting.
- Returns:
- the value read
readInt
public int readInt()
- Read an integer without prompting.
- Returns:
- the value read
readDouble
public double readDouble()
- Read a double without prompting.
- Returns:
- the value read
main
public static void main(java.lang.String[] args)