package iO;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
public class Exr {
public void Compare(File file1,File file2){
try {
Date l1= new Date(file1.lastModified());
Date l2= new Date(file2.lastModified());
System. out .println(l1+" " +l2);
FileReader fr1= new FileReader(file1);
FileReader fr2= new FileReader(file2);
BufferedReader br2= new BufferedReader (fr2);
BufferedReader br1= new BufferedReader (fr1);
String s1= null ;
String s= null;
while ((s=br1.readLine())!= null){
s1=br2.readLine();
if (s.equals(s1)){
System. out .print(s+"\t" );
System. out .println(s1);}
else {
System. out .print(s+"\t" );
System. out .println(s1+"<--此行被更改了" ); }
}
} catch (FileNotFoundException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
} catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
}
public static void main(String[] args) {
Exr ex= new Exr();
ex.Compare( new File( "d:\\123.txt" ), new File("d:\\1222.txt" ));
}
}
50504501 50504501 50504502 50504502 50504503 50504503 50504504 50504504 50504505 50504505 50504506 50504506 50504507 50504507 50504508 50504508 50504509 50504509 50504510 50504510 50504511 505045113<--此行被更改了 50504512 50504512 50504513 50504513
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有