我正在尝试打开JAR作为流,但无法理解从哪里获取此流...
JarInputStream s = new JarInputStream(/* what is here? */);
Run Code Online (Sandbox Code Playgroud)
从哪里获得这个流?我正在尝试打开目前正在负责的JAR.
从我对类似问题的回答:
CodeSource src = MyClass.class.getProtectionDomain().getCodeSource();
if (src != null) {
URL jar = src.getLocation();
ZipInputStream zip = new ZipInputStream(jar.openStream());
/* Now examine the ZIP file entries to find those you care about. */
...
}
else {
/* Fail... */
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
265 次 |
| 最近记录: |