feat: runtime.loadJar() cache dex

This commit is contained in:
hyb1996
2018-10-10 00:31:55 +08:00
parent 94395544b7
commit 6cebca179c
8 changed files with 90 additions and 19 deletions

View File

@@ -395,6 +395,19 @@ public class PFiles {
return file.delete();
}
public static boolean deleteFilesOfDir(File dir) {
if (!dir.isDirectory())
throw new IllegalArgumentException("not a directory: " + dir);
File[] children = dir.listFiles();
if (children != null) {
for (File child : children) {
if (!deleteRecursively(child))
return false;
}
}
return true;
}
public static boolean remove(String path) {
return new File(path).delete();
}

View File

@@ -0,0 +1,26 @@
package com.stardust.util;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5 {
public static byte[] md5Bytes(String message) throws NoSuchAlgorithmException {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(message.getBytes());
return md5.digest();
}
public static String md5(String message) throws NoSuchAlgorithmException {
byte[] bytes = md5Bytes(message);
StringBuilder hexString = new StringBuilder(32);
for (byte b : bytes) {
String hex = Integer.toHexString(0xFF & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
}