jason80
October 12th, 2001, 05:22 PM
Is there a simple way to read in an integer from the keyboard in a console application?
I tried the following code:
String line;
BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
line = reader.readLine();
int a = Integer.parseInt(line);
With this code, Visual Cafe gives me an error on the "reader.readLine()" line mentioning "unreported java.io.IOException. must be caught or declared to be thrown." I tried putting it in a try catch clause, but then it gives me other errors.
Is there another way to get keyboard input?
Thanks.
I tried the following code:
String line;
BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));
line = reader.readLine();
int a = Integer.parseInt(line);
With this code, Visual Cafe gives me an error on the "reader.readLine()" line mentioning "unreported java.io.IOException. must be caught or declared to be thrown." I tried putting it in a try catch clause, but then it gives me other errors.
Is there another way to get keyboard input?
Thanks.