提取 zip 文件:java 还是脚本?
我需要编写一个 java 类,将 zip 文件的内容提取到服务器文件夹中。 最好的方法是什么?您是否建议使用 ZipFile 类,或调用解压缩和复制内容的脚本?
我觉得使用脚本(ant/maven)对于这个任务来说更自然,而Java需要努力读取所有文件和文件。文件夹堆并将它们写入另一个文件夹。
(我需要它来完成安装任务)
谢谢
I need to write a java class that extracts a content of zip file into a server folder.
What is the best way to do it? Do you recommend using ZipFile class, or invoking a script that unzips and copies content?
I feel like using scripts (ant/maven) is more natural for this task, whereas Java needs to work hard to read all the files & folders to heap and write them to another folder.
(I need it for installer task)
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 ZipFile 类。你用什么语言来写剧本?
Use ZipFile class. What language have you used to write the script?
使用单独的应用程序(例如 Ant / Maven /“解压缩”实用程序)可以减少编码工作。但是,它还要求该应用程序在您希望安装程序运行的平台上可用。此外,Ant 和 Maven 通常会要求您创建“build.xml”或“pom.xml”文件来告诉应用程序要做什么。
从这方面来看,Ant 可能是一个不错的选择,因为您可以在安装程序中嵌入相关的 Ant JAR 文件,并且“build.xml”文件非常简单。
但这一切都归结为您认为哪种方法最容易实现......考虑到您的所有要求。
Using a separate application (e.g. Ant / Maven / an "unzip" utility) is less coding work. However, it also requires that the application is available on the platform on which you want your installer to run. Also, Ant and Maven will typically require you to create a "build.xml" or "pom.xml" file to tell the application what to do.
Ant is possibly a good option from this respect because you can embed the relevant Ant JAR file in your installer, and the "build.xml" file can be really simple.
But it all boils down to which approach you think will be easiest to implement ... given all of your requirements.