Feat: cache md5 file value
This commit is contained in:
@@ -68,21 +68,8 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String md5(String path_of_file_) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
InputStream is = Files.newInputStream(Paths.get(path_of_file_));
|
||||
DigestInputStream dis = new DigestInputStream(is, md);
|
||||
byte[] buffer = new byte[8192];
|
||||
while (dis.read(buffer) > 0)
|
||||
; // process the entire file
|
||||
String data = convertBinaryToHex(md.digest());
|
||||
dis.close();
|
||||
is.close();
|
||||
return data;
|
||||
}
|
||||
catch (NoSuchAlgorithmException | IOException e) {
|
||||
return "";
|
||||
}
|
||||
Md5 md5 = new Md5();
|
||||
return md5.get(path_of_file_);
|
||||
}
|
||||
|
||||
public static String convertBinaryToHex(byte[] bytes) {
|
||||
|
||||
Reference in New Issue
Block a user