小编Sam*_*han的帖子

如何使用支持 Zip64 的 ScatterZipOutputStream 实现并行 Zip 创建?

我想知道是否有人可以帮助使用 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();
}
Run Code Online (Sandbox Code Playgroud)

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

java parallel-processing zip apache-commons jakarta-ee

4
推荐指数
1
解决办法
4150
查看次数

python中的无限Fibonacci生成器,产量误差?

def fib_gen():
    a, b = 0, 1
    while True:
        yield a
        a, b = b, a + b

print(next(fib_gen())) 
print(next(fib_gen())) 
print(next(fib_gen())) 
print(next(fib_gen()))

Output: 0 
        0 
        0 
        0
Run Code Online (Sandbox Code Playgroud)

我试图在python中创建一个无限的Fibonacci生成器.请帮忙......我哪里做错了?

python python-3.x

3
推荐指数
2
解决办法
134
查看次数