string tokenizer in Java

From StringTokenizer documentation :

StringTokenizer 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.

The following code should work :

String s = "ABC|DEF||FGHT";
String[] r = s.split("\\|");

Leave a Comment