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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.