【发布时间】:2020-10-26 19:58:18
【问题描述】:
我正在尝试将多个文件压缩到一个存档中,但使用我当前的代码,它只会将其压缩到 zip 中的单个 blob 中。有谁知道如何用 LZ4 分割文件?
public void zipFile(File[] fileToZip, String outputFileName, boolean activeZip)
{
try (FileOutputStream fos = new FileOutputStream(new File(outputFileName), true);
LZ4FrameOutputStream lz4fos = new LZ4FrameOutputStream(fos);)
{
for (File a : fileToZip)
{
try (FileInputStream fis = new FileInputStream(a))
{
byte[] buf = new byte[bufferSizeZip];
int length;
while ((length = fis.read(buf)) > 0)
{
lz4fos.write(buf, 0, length);
}
}
}
}
catch (Exception e)
{
LOG.error("Zipping file failed ", e);
}
}
【问题讨论】: