Assuming I had a text file sample.txt that has info like this:
John-Mike "male" "a computer scientist" 6 9
I want to read in this file into an array where
array[0] = John-Mike
array[1] = male
array[2] = a computer scientist
array[3] = 6
array[4] = 9
i have tried
String[] tokens = file.nextLine().split(" ");
it gives me something like this instead
array[0] = John-Mike
array[1] = male
array[2] = a
array[3] = computer
array[4] = science
array[5] = student
.
.
.
but that splits all the whites paces including the ones in the apostrophe and stores them separately. How do I use split to manipulate this with scanner? I have searched all through the web for a good amount of time for a credible solution but I have found none yet. Any reference or info would be great
EDIT:
You cannot add anything to the text file just to make changes to the delimeter