Using multiple delimiters with StringTokenizer

nikhil picture nikhil · Feb 25, 2012 · Viewed 32.4k times · Source

I'd like to know how I can use multiple delimiters with StringTokenizer in java. For example one of these !,*,/,^ will occur as a delimiter. Also there will only be one at a time.

Answer

MByD picture MByD · Feb 25, 2012

Use the constructor with two arguments, where the second is the delimiters.

StringTokenizer tokenizer = new StringTokenizer(yourString, "!*^/");