使用BufferedReader-java进入while循环

时间:2013-04-04 23:05:59

标签: java while-loop bufferedreader

我完全不知道为什么这不起作用。我以前有类似的循环,他们工作得很好。

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");
        }

0 个答案:

没有答案