You should use a loop that checks to see if there are more tokens and gets the next token in the loop.
Try the following:
StringTokenizer tokenizer = new StringTokenizer("one-two-three", "-");
while (tokenizer.hasMoreTokens()) {
String token = tokenizer.nextToken();
}
source
share