0

我想压缩目录并使用 apache commons compress library 解压缩它,所以

我怎么能做到这一点?

谢谢大家

4

1 回答 1

0

如果你想压缩目录,这里是要走的路

public static void createZip(String directoryPath, String zipPath) throws IOException {
        FileOutputStream fOut = null;
        BufferedOutputStream bOut = null;
        ZipArchiveOutputStream tOut = null;

        try {
            fOut = new FileOutputStream(new File(zipPath));
            bOut = new BufferedOutputStream(fOut);
            tOut = new ZipArchiveOutputStream(bOut);
            addFileToZip(tOut, directoryPath, "");
        } finally {
            tOut.finish();
            tOut.close();
            bOut.close();
            fOut.close();
        }

 }
于 2013-05-25T10:19:53.250 回答