I just got stuck with this BufferedReader and I can't make it to read the whole txt file..it reads only the first line!
FileReader fr = new FileReader("/Users/esson/Desktop/sonnets/sonnet3.txt");
BufferedReader br = new BufferedReader(fr);
String input = br.readLine();
List<String> output= (List) Arrays.asList(input.split(" "));
for(String word: output) {
int times = Collections.frequency(output, word);
System.out.println("" + word+ " -- "+times);
and the output is:
When -- 1
most -- 1
I -- 1
wink -- 1
then -- 1
do -- 1
mine -- 1
eyes -- 1
best -- 1
see, -- 1