Java Scanner class
The Java Scanner class is a class in java.util package , which allows the user to read values of various types. It is a simple text scanner which can parse primitive types and strings using regular expressions . It has a rich set of API which generally used to break down the input to Scanner constructor into tokens . Also, it can parse the tokens into primitive data types using java regular expressions.
The following Java program reads two numbers from the console and display the sum of the numbers.
The following Java program read the contents of a text file by using Scanner.