50,542
社区成员
发帖
与我相关
我的任务
分享
public static String createFileMD5(String filePath) throws Exception {
String md5 = "";
File file = new File(filePath);
if (file.exists()) {
MessageDigest messageDigest = getMD5();
FileInputStream in = new FileInputStream(file);
byte[] cache = new byte[CACHE_SIZE];
while (in.read(cache) != -1) {
messageDigest.update(cache);
}
in.close();
byte data[] = messageDigest.digest();
md5 = byteArrayToHexString(data);
}
return md5;
}
for (int i; (i = in.read(cache)) >= 0;) {
messageDigest.update(cache, 0, i);
}