如何在支持Zip64的ScatterZipOutputStream中实现并行Zip创建?

时间:2019-02-11 05:56:30

标签: java java-ee parallel-processing zip apache-commons

我想知道是否有人可以使用ScatterZipOutputStream帮助实现并行Zip创建。我进行了很多搜索,但没有找到相同的示例。

https://commons.apache.org/proper/commons-compress/zip.html

我尝试使用ZipArchiveOutputStream制作Zip,压缩目录等。现在,我正在尝试并行执行此操作。

public static void makeZip(String filename) throws IOException,
        ArchiveException {
    File sourceFile = new File(filename);

    final OutputStream out = new FileOutputStream(filename.substring(0, filename.lastIndexOf('.')) + ".zip");
    ZipArchiveOutputStream os = new ZipArchiveOutputStream(out);
    os.setUseZip64(Zip64Mode.AsNeeded);

    os.putArchiveEntry(new ZipArchiveEntry(sourceFile.getName()));
    IOUtils.copy(new FileInputStream(sourceFile), os);
    os.closeArchiveEntry();
    os.close();
}

它应该能够将单个文件作为线程处理,然后将其组合以编写结果zip。

1 个答案:

答案 0 :(得分:0)

以下是public class PlaceMeOnTarget() { public void PlaceOnTarget(TargetFoundEventHandler target) { transform.SetPositionAndRotation(target.transform.position, target.transform.rotation); // optinally remove the callback so this object // will not be placed elsewhere target.onTrackingFound.RemoveListener(PlaceOnTarget); } } zip的工作代码:
1.更改unzipsourceFolder的路径
2.仅压缩* .text类型的文件,可以是任何类型或所有文件
3.在zipFilePath

解压缩的文件

在build.gradle或pom.xml中导入以下依赖项

sourceFolder/unzip/

参考:https://mvnrepository.com/artifact/org.apache.commons/commons-compress/1.18 https://mvnrepository.com/artifact/commons-io/commons-io/2.6

//代码

implementation("org.apache.commons:commons-compress:1.18")
implementation("commons-io:commons-io:2.6")

参考:Fast zipping folder using java ParallelScatterZipCreator