1.文件在服務器上面,根據www.xxx等去取的
int size;
// 路徑
URL url = new URL(log_path);
// 去文件
URLConnection conn = url.openConnection();
// 得到文件大小
size = conn.getContentLength();
// 得到文件流
InputStream in = conn.getInputStream();
// 文件加密
String fileMD5 = DigestUtils.md5Hex(in);
2
// 路徑
String log_path = AppUtils.getWebRootPath() + data.get("curVerUrl");
// 文件路徑加密
String fileMD5 = DigestUtils.md5Hex(new FileInputStream(log_path));
File file = new File(log_path);
// 文件大小
System.out.println("文件加密后:"+fileMD5+",大小為:"+file.length());
data.put("fileSize", file.length()+"");
data.put("fileMD5", fileMD5);