赞
踩
1、读取文件逐个字节比较:
public static boolean isFileUpdate(String oldName, String newName) {
File oldFile = new File(oldName);
File newFile = new File(newName);
try {
FileInputStream oldInStream = new FileInputStream(oldFile);
FileInputStream newInStream = new FileInputStream(newFile);
int oldChar = 0;
int newChar = 0;
while (true) {
oldChar = oldInStream.read();
newChar = newInStream.read();
if (oldChar != -1 && newChar != -1) {
if (oldChar != newChar) {
return false;
}
} else {
break;
}
}
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。