从 InputStream 创建 JarFile
Create JarFile from InputStream
我想从 Internet 读取 JarFile 到 ram 并将其作为 JarFile 处理。
有没有办法在不先保存的情况下将 JarInputStream 转换为 JarFile 或将 byte[] 转换为 JarFile?
倍数为 55283
public static void update() throws Exception {
HttpURLConnection conn = (HttpURLConnection) new URL("https://api.spiget.org/v2/resources/" + plid).openConnection();
JSONObject info = (JSONObject) new JSONParser().parse(new InputStreamReader(conn.getInputStream()));
long dwlid = Long.parseLong( ((JSONObject) ((JSONArray) info.get("versions")).get(0)).get("id").toString() );
String dwl = String.format("https://api.spiget.org/v2/resources/{0}/versions/{1}/download", plid, dwlid);
conn = (HttpURLConnection) new URL(dwl).openConnection();
conn.setRequestProperty("user-agent", Core.useragent);
conn = f(conn);
InputStream in = conn.getInputStream();
JarInputStream jis = new JarInputStream(in);
JarFile jf = new Jar
}
不幸的是 java.util.jar.JarFile
和 java.util.zip.ZipFile
只能在 File
上运行。
而且真正读取文件的部分是原生实现的。因此,从我的角度来看,覆盖 class 并将实现重定向到 byte[]
或任何其他类型的缓冲区似乎是不可行的。
我想从 Internet 读取 JarFile 到 ram 并将其作为 JarFile 处理。 有没有办法在不先保存的情况下将 JarInputStream 转换为 JarFile 或将 byte[] 转换为 JarFile?
倍数为 55283
public static void update() throws Exception {
HttpURLConnection conn = (HttpURLConnection) new URL("https://api.spiget.org/v2/resources/" + plid).openConnection();
JSONObject info = (JSONObject) new JSONParser().parse(new InputStreamReader(conn.getInputStream()));
long dwlid = Long.parseLong( ((JSONObject) ((JSONArray) info.get("versions")).get(0)).get("id").toString() );
String dwl = String.format("https://api.spiget.org/v2/resources/{0}/versions/{1}/download", plid, dwlid);
conn = (HttpURLConnection) new URL(dwl).openConnection();
conn.setRequestProperty("user-agent", Core.useragent);
conn = f(conn);
InputStream in = conn.getInputStream();
JarInputStream jis = new JarInputStream(in);
JarFile jf = new Jar
}
不幸的是 java.util.jar.JarFile
和 java.util.zip.ZipFile
只能在 File
上运行。
而且真正读取文件的部分是原生实现的。因此,从我的角度来看,覆盖 class 并将实现重定向到 byte[]
或任何其他类型的缓冲区似乎是不可行的。