import java.io.*;import java.util.*;public class File_operation {public void read_file(String filename,ArrayList<String> a) { BufferedReader br = new BufferedReader(new FileReader(filename)); String line1 = ""; String line2 = ""; while ((line1 = br.readLine()) != null) { a.add(line1); line1 = br.readLine(); while (!line1.equals("\n")){ //这里竟然每次都进去了。怎么可能? line2 += line1; line1=br.readLine(); System.out.println(line1); } a.add(line2); a.add(line1); line2 = "";}br.close();第一张图是文件里的内容,照理来说是在读到空行时候停止跳出第二个while的,但是却没跳,实在想不通,求教!! 是非!运算的使用不对吗?
添加回答
举报
0/150
提交
取消