while EOF in JAVA?

后端 未结 7 1407
难免孤独
难免孤独 2020-12-17 06:21

Following to some forums answers I\'m using this:

    while (fileReader.nextLine() != null) {
        String line = fileReader.nextLine();
        System.out         


        
7条回答
  •  时光取名叫无心
    2020-12-17 06:49

    nextLine() will throw an exception when there's no line and it will never return null,you can try the Scanner Class instead : http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html

提交回复
热议问题