public staticString getFileMD5(File file){
if(!file.isFile()) {
return null;
}
MessageDigest digest;
FileInputStream fis;
byte[] buffer =new byte[1024];
try{
if(!file.isFile()) {
return"";
}
digest = MessageDigest.getInstance("MD5");
fis =newFileInputStream(file);
while(true) {
intlen;
if((len = fis.read(buffer,0,1024)) == -1) {
fis.close();
break;
}
digest.update(buffer,0, len);
}
}catch(Exception e) {
e.printStackTrace();
return null;
}
BigInteger var5 =newBigInteger(1, digest.digest());
returnString.format("%1$032x", var5);
}
网友评论