The StringTokenizer class
The base.StringTokenizer
class is designed to parse a string to
extract tokens based on delimiters.
The steps to use a string tokenizer are:
- Define a variable of the
base.StringTokenizer
type. - Create the string tokenizer object with one of the create methods, passing the string to be parsed as parameter.
- Optionally, count the number of tokens with
countTokens()
before processing. - Use a
WHILE
loop to process the different tokens, by usinghasMoreTokens()
as loop condition andnextToken()
inside the loop body to get the next token.