November 2005
Intermediate to advanced
304 pages
6h 14m
English
In the previous section, we read a data file using the Scanner class in Java 5. It was simple enough, because each line had the same structure. What if we wanted to read a data file that has a structure that is different for each line of text? A Matcher wouldn't work, because it can use only a single regex. The Scanner can be used for these kinds of tasks, because you can use regular expressions on the input text to look ahead for patterns in the upcoming text. Because you can read the input on a token-by-token basis, you can write custom parsers for any kind of text. Let's illustrate ...
Read now
Unlock full access