AlgoMaster Logo

Scanner Class

Last Updated: June 6, 2026

Medium Priority
23 min read

java.util.Scanner is a token-based parser that reads text from a file, an input stream, a string, or the keyboard and hands back ready-to-use primitive values and strings. It was added in Java 5 and is the easiest way to pull structured input out of a small text file without writing any parsing logic. This lesson covers how Scanner views its input, how to construct one from common sources, the token and line methods, the newline trap, custom delimiters, locale-sensitive number parsing, and when to use a different tool.

Premium Content

Subscribe to unlock full access to this content and more premium articles.