The second parameter to the constructor of StringTokenizer object is just a string containing all delimiters that you require.
StringTokenizer st = new StringTokenizer(str, "@!");
In this case, there are two delimiters both @ and !
Consider this example :
String s = "Hello, i am using Stack Overflow;";
System.out.println("s = " + s);
String delims = " ,;";
StringTokenizer tokens = new StringTokenizer(s, delims);
while(tokens.hasMoreTokens())
System.out.println(tokens.nextToken());
Here you would get an output similar to this with 3 delimiters :
Hello
,
i
am
using
Stack
Overflow
;
StringTokenizerjavadocs stateStringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.so you should be looking at the answers provided by mcfinnigan and Francois.