I need some help with a splitting a text file with java. I have a text file with around 2000 words, the text file is in the format as follows -
"A", "HELLO", "RANDOM", "WORD"... etc
My goal is to put these words into a string array. Using the scanner class I'm taking the text and creating a string, then trying to split and add to an array as follows.
Scanner input = new Scanner(file);
while(input.hasNext()){
String temp = input.next();
String[] wordArray = temp.split(",");
}
After added to the array, when I want to use or print each element, they are stored with the "" surrounding them. Instead of printing
A
HELLO
RANDOM
… etc they are printing
"A"
"HELLO"
"RANDOM"
So my question is how can I get rid of these regular expressions and split the text at each word so I'm left with no regular expressions?
Many Thanks