I want to read and separate a comma separated list, but I only want the StringTokenizer to use the comma to separate the words and not whitespace. I set the code as:
String text = "black white,blue green"
StringTokenizer st = new StringTokenizer(myString, ",");
String[] list = new String[2];
int count = 0;
while (st.hasMoreTokens()){
list[count] = st.nextToken();
count++;
}
I want "black white" to go into list[0], and "blue green" to go into list[1], however the StringTokenizer still separates the list on white spaces as well as the commas, and I end up with an IndexOutOfBoundsException occuring.
Any suggestions???