Using the StringTokenizer Class

There are times when you are dealing with Strings that must be broken up into pieces or into multiple Strings. Where the strings are broken apart depends on which delimiters are specified for the tokenization process. By default, a space is used to separate the strings, but you can also use any other character to separate the tokens.

Imagine if you had to parse through a text file of words and separate each word so that later you could perform a query and determine if a particular word was in your search list and how many times it appeared. As you can see, searching through a large String and looking for beginnings and endings of words could be tedious and take some effort. Fortunately for Java developers, you ...

Get Special Edition Using Java 2 Standard Edition 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.