1

我完全不知道为什么这不起作用。我以前有过类似的循环,它们运行良好。

try{
    text = new BufferedReader(new FileReader(fileName));

    while ((lineOfText = text.readLine()) != null){
                StringTokenizer tokens = new     StringTokenizer(lineOfText," , .;:\"&!?-_\n\t12345678910[]{}()@#$%^*/+-");
                while (tokens.hasMoreTokens()){
                    countTotalWordsInDocument++;
                    String word = tokens.nextToken();
                    countTotalCharactersInAllWords = countTotalCharactersInAllWords + word.length();
                }
            }
            text.close();
        } catch (IOException e) {
            System.out.println("file not found");
        }
4

0 回答 0