每个文件都有一个MD5值,都不一样
/**
* 获取上传文件的md5
*
* @param file
* @return
* @throws java.security.NoSuchAlgorithmException
* @throws java.io.IOException
*/
public static String getMd5(MultipartFile file) {
try {
byte[] uploadBytes = file.getBytes();
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] digest = md5.digest(uploadBytes);
String hashString = new BigInteger(1, digest).toString(16);
return hashString;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//获取文件大小
public static final String getSize(MultipartFile file) {
String size = "";
long fileLength = file.getSize();
DecimalFormat df = new DecimalFormat("#.00");
if (fileLength < 1024) {
size = df.form