public static void main(String [] args) throws IOException {
/*创建字符缓冲输入流对象
* 1 待检测值
* 2 标准值*/
BufferedReader br1 = new BufferedReader(new FileReader("C:\\Users\\谁家小朋友鸭\\Desktop\\1.txt"));
BufferedReader br2 = new BufferedReader(new FileReader("C:\\Users\\谁家小朋友鸭\\Desktop\\2.txt"));
//创建ArrayList集合对象
ArrayList<String> array1 = new ArrayList<String>();
ArrayList<String> array2 = new ArrayList<String>();
//调用字符缓冲输入流对象的方法读数据
String line1;
while ((line1 = br1.readLine()) != null) {
//把读取到的字符串数据存储到集合中
array1.add(line1);
}
String line2;
while ((line2 = br2.readLine()) != null) {
//把读取到的字符串数据存储到集合中
array2.add(line2);
}
//释放资源
br1.close();
br2.close();
以文件的形式传入数据
于 2022-01-29 09:16:33 首次发布