Java网络教程:JarURLConnection

原文链接

Java的JarURLConnection类用来连接Java Jar文件。一旦连接上,你可以获取Jar文件的信息。一个简单的例子如下:

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...

原创文章,转载请注明: 转载自并发编程网 – ifeve.com本文链接地址: Java网络教程:JarURLConnection



司余

司余

积少成多, 聚沙成塔
司余

Latest posts by 司余 (see all)

FavoriteLoading添加本文到我的收藏
  • 4,639 人阅读
  • 1 comment
  • Trackback are closed
  • Comments (1)
    • msi1993
    • 04/21. 2017 5:09pm

    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

You must be logged in to post a comment.

return top