阅读(在运行时)的JAR文件的内容? [英] Reading content of a JAR file (at runtime)?

查看:127
本文介绍了阅读(在运行时)的JAR文件的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了帖子:

<一个href=\"http://stackoverflow.com/questions/320510/viewing-contents-of-a-jar-file\">http://stackoverflow.com/questions/320510/viewing-contents-of-a-jar-file


<一href=\"http://stackoverflow.com/questions/1429172/list-files-inside-a-jar\">http://stackoverflow.com/questions/1429172/list-files-inside-a-jar

但我遗憾的是,无法找到一个很好的解决实际阅读的JAR的内容(由档案文件)。

But I, sadly, couldn't find a good solution to actually read a JAR's content (file by file).

此外,可能有人给我一个提示,或指向一个资源,在这里我的问题进行了讨论?

Furthermore, could someone give me a hint, or point to a resource, where my problem is discussed?

我能想到的一个不那么直接的路要做到这一点:

我可以一个JAR的资源的列表以某种方式转换的列表
内-JAR的URL,然后我可以打开使用的openConnection()。

推荐答案

您使用的 jar文件打开一个JAR文件。有了它,你可以通过使用'getEntry(字符串名称)'或'entires的ZipEntry或的JarEntry(它们可以被看作是同样的事情)获得。一旦你得到的条目,你可以用它通过调用来获得InputStream的<一个href=\"http://www.j2ee.me/j2se/1.4.2/docs/api/java/util/jar/JarFile.html#getInputStream%28java.util.zip.ZipEntry%29\"相对=nofollow> JarFile.getInputStream(ZipEntry的泽)。那么你可以从流中读取数据。

You use JarFile to open a Jar file. With it you can get ZipEntry or JarEntry (they can be seen as the same thing) by using 'getEntry(String name)' or 'entires'. Once you get an Entry, you can use it to get InputStream by calling 'JarFile.getInputStream(ZipEntry ze)'. Well you can read data from the stream.

请参阅教程 rel=\"nofollow\">。

See a tutorial here.

这篇关于阅读(在运行时)的JAR文件的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆