public static int numberOFWords(FileReader r) throws IOException {
BufferedReader b = new BufferedReader(r);
String line = "";
String page = "";
int count= 0;
String[] array;
while ((line = b.readLine())!= null)
page += line+ " ";
StringTokenizer st = new StringTokenizer(page);
array = new String[st.countTokens()];
while (st.hasMoreTokens()) {
array[count] = st.nextToken();
count++;
}
b.close();
return count;
}
}
Ta metoda ma zliczać ilość słów w pliku, ale cały czas zwraca że słów jest 0. Gdzie popełniłam błąd?