java.util.StringTokenizer class is used
to break strings into tokens (words, numbers, operators, or whatever).
A more powerful solution is to use regular expressions,
which have been added to Java 1.4.
nextToken() method is called, it returns the
next token in that string.
If you don't specify the delimiters
(separator characters), blanks are the default.
StringTokenizer st = new StringTokenizer(s);StringTokenizer st = new StringTokenizer(s, d);StringTokenizer st = new StringTokenizer(s, d, f);true, each delimiter character will also be
returned as a token.st is a StringTokenizer.
st.hasMoreTokens() -- Returns true if there are more tokens.st.nextToken() -- Returns the next token as a String.st.countTokens() -- Returns the int number of tokens.
This can be used to allocate an array before starting, altho it can be
inefficient for long strings because it has to scan the string once just to get this number.
Using a Vector and converting it to an array at the end may be a better choice.
<