用于将整个存档解压缩到java中的目录的实用程序 [英] Utility to unzip an entire archive to a directory in java

查看:111
本文介绍了用于将整个存档解压缩到java中的目录的实用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的程序中执行以下操作:

I'd like to do something like this in my program:

File zipFile = .....;
File destDir = ....;    
ImaginaryZipUtility.unzipAllTo(zipFile, destdir);

我不可能是第一个从程序中执行此操作的人。我在哪里找到像上面这样的实用方法?我试着看看apache commons-io,但没有。那么,我应该在哪里看看?

I cannot possibly be the first to do this from a program. Where do I find a utility method like above? I tried to look at apache commons-io, but nothing there. So, where should I look?

推荐答案

似乎可以使用TrueZip库做我想做的事:
https://truezip.dev.java.net/manual-6.html #Copying

It seems like it's possible to do what I want using the TrueZip library: https://truezip.dev.java.net/manual-6.html#Copying

这不是一个理想的情况,因为这个库非常大,范围比我需要的大(而且还有一些特殊和令人困惑的详细信息,例如围绕java.io.File的子类进行组织,这些子类也称为File,用于通常也处理java.io.File实例的类!)。

This is not an ideal situation, since the library is quite large and with a larger scope than I need (and also with some peculiar and confusing details such as being organized around subclasses of java.io.File which are also called File for use in classes that typically also handles java.io.File instances!).

至少我不必处于这样一种情况,即类中的大多数代码行与类的职责无关,或者在项目中维护一个与模块目的无关的复杂实用程序类。 。

At least I don't have to be in a situation where a majority of the code lines in the class are unrelated to the responsibility of the class, or to maintain a complex utility class in the project that is unrelated to the purpose of the module.

我认为这是有经验的开发人员从Java迁移到Ruby的主要原因的典型示例。尽管java中有大量的库,但是它们中的很多都设计得很差,因此简单的操作变得和更专业的操作一样难以执行。似乎它们是自下而上由技术专家编写的,他们更渴望揭示所有细节和可能性,而不是简单地完成日常任务。 apache commons人们应该荣幸地创建库来减轻你的类与代码行,尤其是循环和条件,这与类的业务目的无关。

I think this is a typical example on the main reason why experienced developers are migrating from Java to Ruby. Despite an abundance of libraries in java, too many of them are poorly designed so that simple operations become just as difficult to perform as the more specialized ones. Seems like they are written from the bottom up by technology experts more eager to expose all details and possibilities than to make everyday tasks simple. The apache commons people deserves honor for creating libraries that relieve your class from code lines, especially loops and conditionals, that are unrelated to the business purpose of the class.

这篇关于用于将整个存档解压缩到java中的目录的实用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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