📄 e138. getting a jar file using a url.txt
字号:
try {
// Create a URL that refers to a jar file on the net
URL url = new URL("jar:http://hostname/my.jar!/");
// Create a URL that refers to a jar file in the file system
url = new URL("jar:file:/c:/almanac/my.jar!/");
// Get the jar file
JarURLConnection conn = (JarURLConnection)url.openConnection();
JarFile jarfile = conn.getJarFile();
// When no entry is specified on the URL, the entry name is null
String entryName = conn.getEntryName(); // null
// Create a URL that refers to an entry in the jar file
url = new URL("jar:file:/c:/almanac/my.jar!/com/mycompany/MyClass.class");
// Get the jar file
conn = (JarURLConnection)url.openConnection();
jarfile = conn.getJarFile();
// Get the entry name; it should be the same as specified on URL
entryName = conn.getEntryName();
// Get the jar entry
JarEntry jarEntry = conn.getJarEntry();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -