A simple text scanner in the JDK which can parse primitive types and strings using regular expressions.
Use this tag for questions related to the Java API library class java.util.Scanner
, a class added to the API in Java 5. The class is, according to the Javadoc:
a simple text scanner which can parse primitive types and strings using regular expressions.
Its source can range from a file, the console, or even a string. (This class replaces the older class java.util.StringTokenizer
, which was used prior to Java 5 for the same purpose but has less functionality compared to Scanner
).
Important canonical posts with this tag are:
- How to use Scanner to correctly read user input from System.in and act on it?
- Skipping nextLine() after using next(), nextInt() or other nextFoo() methods
- Scanner vs. BufferedReader
Related tags: