public static int getWords(String filename) {
try {
final File fl = new File(filename);
final Scanner sc = new Scanner(fl);
int count = 0;
while(sc.hasNextLine()) {
count += sc.nextLine().split(" ").length;
}
sc.close();
return count;
} catch (FileNotFoundException ex) {
return -1;
}
}
String[] words = deinString.split(" ");
int wordCount = words.length;
tim; tim; tomas; tim; tomas; peter; tim
Danke für die Hilfe!
aber eine Frage noch (ich bin sehr dumm bei so komplizierteren Sachen)
Aber wenn ich eine Sache mal nicht raffe heißt es ja nicht, dass ich es gar nicht kann