All Packages Class Hierarchy This Package Previous Next Index
Class jnt.io.NumericReader
java.lang.Object
|
+----jnt.io.NumericReader
- public class NumericReader
- extends Object
An easy interface to read numbers and strings from
standard input.
Example use:
NumericReader R = new NumericReader( new FileReader("foo.dat"));
double x = R.readDouble();
int i = R.readInt();
String s = R.readWord();
String l = R.readLine();
public variable: R.Reader_ can be used in functions
or
NumericReader R = new NumericReader(new InputStreamReader(System.in));
-
Reader_
-
-
NumericReader(Reader)
-
-
readDouble()
- read a floating point number from the console.
-
readInt()
- read an integer from the console.
-
readLine()
- read a line from a charater input stream.
-
readWord()
- read a word from the console.
Reader_
public Reader Reader_
NumericReader
public NumericReader(Reader in)
readLine
public String readLine()
- read a line from a charater input stream. The string is
terminated by a newline
- Returns:
- the input line (without the newline)
readWord
public String readWord() throws IOException
- read a word from the console. The word is
the first set of contiguous non-whitespace characters
- Returns:
- the 'word' entered
readInt
public int readInt() throws IOException
- 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
readDouble
public double readDouble() throws IOException
- 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
All Packages Class Hierarchy This Package Previous Next Index