Using multiple delimiters with StringTokenizer
-
12-11-2019 - |
Question
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.
Solution
Use the constructor with two arguments, where the second is the delimiters.
StringTokenizer tokenizer = new StringTokenizer(yourString, "!*^/");
OTHER TIPS
You can use String.split() method because it takes regex as a parameter. You can specify Regex such that it can split the string based upon one of these deliminators.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow