You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
have access to post topics
communicate privately with other members (PM)
not see advertisements between posts
have the possibility to earn one of our surprises if you are an active member
access many other special features that will be introduced later.
The static method below reads only int values using BufferedReader (stdin) and throws Exception if int is not read.
Code:
public static int readInt () {
while (true) {
try{
String line = stdin.readLine();
int value = Integer.parseInt(line);
return value;
} catch(java.lang.NumberFormatException e){
;
} catch(IOException e){
;
}
}
} // end readInt ()
As you are probably aware, there are typically more than one way to perform a task in Java.
Just wanted to welcome you to our community. See you around!
-Capt
__________________
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. to our beloved Java Forums! (closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. !
Got a little Capt'n in you? (drink responsibly)