English 中文(简体)
使用 Java 正在使用 Java 解zi一个多部分的拉链文件卷
原标题:Unzipping a multi-part zip file volumes using Java

我需要解开一组作为 zip 归档的文档。 这不是一组 zip 文件, 而是一个大的 zip 文件, 已经根据大小要求 被分割成多个 zip 文件 。

例如,如果您有一个 2.5MB zip 文件, 您的邮件系统只支持 1MB 文件, 您可以请 Zip 创建最多为 1MB 的 3 个文件 。

所以它创造了一个zip.001, a.zip.002, a.zip.003... 不同的图书馆 名称不同,但基本上它们的工作方式都一样。

你如何在 Java 解开它? 它看起来不像在 std 中的压缩 libs 支持它 。

谢谢

最佳回答

尝试将所有文件合并成单个文件, 然后提取单个文件。 例如 :

    File dir = new File("D:/arc");
    FileOutputStream fos = new FileOutputStream(new File(
            "d:/arc/archieve-full.zip"));
    FileInputStream fis = null;
        Set<String> files = new TreeSet<String>();
        for (String fname : dir.list()) {
            files.add(fname);
        }
        for (String fname : files) {
        try {
            fis = new FileInputStream(new File(dir.getAbsolutePath(), fname));
            byte[] b = new byte[fis.available()];
            fis.read(b);
            fos.write(b);
        } finally {
            if (fis != null) {
                fis.close();
            }
            fos.flush();
        }
    }
    fos.close();
    ZipFile zipFile = new ZipFile("d:/arc/archieve-full.zip");
    /*extract files from zip*/

更新: 使用 < code> TreeSet 来排序文件名称, 因为 < code> dir. list () 不保证字母顺序 。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签