Java网络教程:JarURLConnection
Java的JarURLConnection类用来连接Java Jar文件。一旦连接上,你可以获取Jar文件的信息。一个简单的例子如下:
[code lang=”java”]
String urlString = "http://butterfly.jenkov.com/"
+ "container/download/"
+ "jenkov-butterfly-container-2.9.9-beta.jar";
URL jarUrl = new URL(urlString);
JarURLConnection connection = new JarURLConnection(jarUrl);
Manifest manifest = connection.getManifest();
JarFile jarFile = connection.getJarFile();
//do something with Jar file…
[/code]
原创文章,转载请注明: 转载自并发编程网 – ifeve.com本文链接地址: Java网络教程:JarURLConnection
JarURLConnection是抽象类 无法实例化
Users should cast the generic URLConnection to a JarURLConnection when they know that the URL they created is a JAR URL, and they need JAR-specific functionality. For example:
URL url = new URL(“jar:file:/home/duke/duke.jar!/”);
JarURLConnection jarConnection = (JarURLConnection)url.openConnection();
Manifest manifest = jarConnection.getManifest();
http://docs.oracle.com/javase/8/docs/api/java/net/JarURLConnection.html