while (scan.hasNextLine()) {
String thisline = scan.nextLine();
totalnumber.countthelines++; //linecount works
for(int i = 0; i < thisline.length();i++){
totalnumber.charactercounter++; //chararacter count works
String [] thewords = thisline.split (" ");
totalnumber.wordcounter = thewords.length; //does not work
}
}
ワードカウンターが機能しません (既に文字数と行数を数えることができます)。私はそれを機能させるためにさまざまな方法を試しましたが、常に読み込まれたファイルの最後の行からの単語のみをカウントすることになります。最後の行だけでなく、すべての行を読み取る方法について何か提案はありますか? ありがとう