Partially Parseable: Parsing with the Scanner Class

Java 5 added the java.util.Scanner class, a new utility for scanning input text. It's something of a cross between the older StringTokenizer and the Matcher class. In previous sections we used a Matcher to search within a String to find data that matched a given pattern. This was useful, but we were limited to matching only a single pattern. Any data had to be retrieved by capturing groups within the same pattern or by using an index to retrieve portions of the text. We used a combination of regular expressions and methods that retrieve items of specific types from an input stream. In addition ...

Get Wicked Cool Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.