[英]How do you make a function similar to jar -uf in Java?
Using the standard Java API (ie the user doesn't need the JDK to run it), how do you make a function similar to jar -uf in Java? 使用标准的Java API(即用户不需要JDK来运行它),如何在Java中创建类似于jar -uf的函数? I have an idea that it will use the Zip library, unzip the .jar file, change the contents, and then rezip it, but I'm a newbie at Java, so I cannot really make it.
我有一个想法,它将使用Zip库,解压缩.jar文件,更改内容,然后重新压缩它,但是我是Java的新手,所以我真的做不到。 Could you give an example or a function?
您能举个例子还是一个函数?
Thanks! 谢谢!
Edit: I think I found the answer here: How to use JarOutputStream to create a JAR file? 编辑:我想我在这里找到了答案: 如何使用JarOutputStream创建JAR文件? I'll see if it works.
我看看它是否有效。
Take a look at JarInputStream , JarOutputStream , ZipInputStream , and ZipOutputStream . 看看JarInputStream , JarOutputStream , ZipInputStream和ZipOutputStream 。 They are a part of the JDK, so external libraries are not required.
它们是JDK的一部分,因此不需要外部库。 Pay attention that unlike other streams these require you to care about current entry.
请注意,与其他流不同,这些流需要您关心当前条目。 You can find a lot of examples of how to use the java zip API.
您可以找到许多有关如何使用Java zip API的示例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.