I get jar files from net. I've been able to open it and to search for a file(.txt file) that I need inside it. For doing that I am using JarEntry and method getNextJarEntry(). Finally when I identify the file I need I would like to save it in some directory on my disc. I don't know how to do this. The object I have after file identification is JarEntry which corresponds to the file I want to save. Can anybody suggest me a way how to store the file I need?
My bad, I only have JarInputStream and not the jar itself.
在原始的JarFile
对象上,您可以传递JarEntry
并获取InputStream
:
InputStream getInputStream(ZipEntry ze)
使用JarFile.getInputStream(ZipEntry)
方法,从输入流中读取所有字节,然后将它们写入FileOutputStream。
您可以使用自定义类加载器( java.net.URLClassloader
)加载JAR,然后使用getResourceAsStream
获取资源。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.