java.util.Scanner

 

Scanner
Tutorial on Regular Expressions and their package
Pattern

Enhanced Input: Prior to J2SE 5.0, in order to read an integer value from the keyboard, it has to be read as a String and then parsed as follows (this code doesn't include the try and catch constructs):

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
int n = Integer.parseInt(str);



In J2SE 5.0, the java.util.Scanner class can be used to accomplish the same thing but with less code as follows:

Scanner reader = new Scanner(System.in);
int n = reader.nextInt();



"Programming educators are going to love this enhanced input functionality, as it will make it easy to explain how to read primitive data types from the keyboard."

 

From Java tech Tips: http://java.sun.com/developer/JDCTechTips/2004/tt1201.html#1