我想知道是否有人可以使用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。
答案 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.更改unzip
和sourceFolder
的路径
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")