JarFile是从* .jar还是输入流输入到文件? [英] JarFile from inside a *.jar or inputstream to file?

查看:67
本文介绍了JarFile是从* .jar还是输入流输入到文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个罐子或罐子.

我正在以编程方式读取这个jar,当我在这个jar中找到一个jar时,我想再次以编程方式阅读它.

I'm programmaticaly reading this jar, and when I find jar inside this jar I'd like to programmaticaly read it again.

但是JarFile仅提供getInputStream,我无法将其传递给JarFile(File file)构造函数.

But JarFile provides only getInputStream, which I cannot pass to JarFile(File file) constructor.

如何从jar中读取jar?

How to read jar from jar?

我正在考虑以某种方式从类加载器中获取文件.

I was thinking about getting the File somehow from classloader or so.

推荐答案

您可以在文件系统中创建jar文件,例如

you can create jar file in File System, something like

 File tempFile=TempFile.createFile("newJar",".jar");

并将Stream写入其中.之后,您可以构造JarFile(tempFile)并对其进行处理...

and write Stream into it. After that you can construct your JarFile(tempFile) and handle it...

如果程序以未签名的applet/JNLP的身份运行,请不要理会它,因为您无权在文件系统中创建文件...

Forget about it if program is running as unsigned applet/JNLP since you will not have right to create file in file system...

这篇关于JarFile是从* .jar还是输入流输入到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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