计算文件的 MD5 值
来源:互联网 发布:mac软件卸载不了 编辑:程序博客网 时间:2024/05/17 23:47
// 计算文件的 MD5 值
private String getFileMD5(File file)
{
if (!file.isFile())
{
return null;
}
MessageDigest digest = null;
FileInputStream in = null;
byte buffer[] = new byte[8192];
int len;
try
{
digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
while ((len = in.read(buffer)) != -1)
{
digest.update(buffer, 0, len);
}
BigInteger bigInt = new BigInteger(1, digest.digest());
return bigInt.toString(16);
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
finally
{
try
{
in.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
private String getFileMD5(File file)
{
if (!file.isFile())
{
return null;
}
MessageDigest digest = null;
FileInputStream in = null;
byte buffer[] = new byte[8192];
int len;
try
{
digest = MessageDigest.getInstance("MD5");
in = new FileInputStream(file);
while ((len = in.read(buffer)) != -1)
{
digest.update(buffer, 0, len);
}
BigInteger bigInt = new BigInteger(1, digest.digest());
return bigInt.toString(16);
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
finally
{
try
{
in.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
0 0
- 计算文件的md5值
- 计算文件的MD5值
- 计算文件的MD5值
- 计算文件的MD5值
- 计算文件的 MD5 值
- 计算文件的MD5
- 计算文件的md5
- 文件MD5值计算
- 计算字符串的MD5值和MD5文件摘要
- 用python计算文件的md5值
- C# 计算文件的MD5值
- C# 计算文件的MD5值
- 计算文件的MD5值(.Net)
- 用python计算文件的md5值
- Linux下计算文件的MD5值
- JAVA计算文件的MD5值
- 用C#计算文件的MD5值
- JAVA计算文件的MD5值
- 盾神与条状项链
- Centos搭建docker环境
- Hibernate深入Session
- 欢迎使用CSDN-markdown编辑器
- 胡侃软件开发之C#的委托
- 计算文件的 MD5 值
- 正则验证数字
- 第一天学习powershell总结
- Android开发:最全面、最易懂的Android屏幕适配解决方案
- 采集获取网页内容
- 【Python爬虫系列】内容解析之BeautifulSoup
- html转image--通过html2canvas在浏览器端处理
- 写在17年开始
- 写hibernate的基本方法