public static void main(String[] args) throws Exception {
String file1 = "file1.txt";
String file2 = "file2.txt";
ArrayList<String> list1 = addToList(file1);
ArrayList<String> list2 = addToList(file2);
String s1 = list1.get(0);
String s2 = list2.get(1);
if (!s1.equals(s2)){
System.out.println("不同==="+s1+"==="+s2+"===");
}
}
static ArrayList<String> addToList(String file) throws Exception {
ArrayList<String> lines = new ArrayList<>();
BufferedReader br = null;
br = new BufferedReader(new FileReader(file));
String strLine = null;
while ((strLine = br.readLine()) != null){
strLine = strLine.trim();
if ( strLine != ""){
lines.add(strLine);
}
}
return lines;
}
添加回答
举报
0/150
提交
取消