I have a comma-seperated value string in Java:
String s = "a,b,c,d";
I need to tokenize it (with comma as the delimiter) and turn it into a Set<String>
. Is StringTokenizer
my best bet or is there a more efficient way?
If you try to solve generally CSV parsing to set be aware that there are quotes and coma escaping to handle. This is why libraries like OpenCSV exist. Otherwise you just need to do as hvgotcodes described.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With