Java不压缩5G 7z文件

Java不压缩5G 7z文件,java,7zip,apache-commons-compress,Java,7zip,Apache Commons Compress,我正在尝试解压缩版本为1.9的5G文本文件 public String unZipFile(String pathFileName, String saveFilePath) throws IOException { SevenZFile sevenZFile = new SevenZFile(new File(pathFileName)); SevenZArchiveEntry entry = sevenZFile.getNextEntry(); try {

我正在尝试解压缩版本为1.9的5G文本文件

public String unZipFile(String pathFileName, String saveFilePath)  throws IOException {

    SevenZFile sevenZFile = new SevenZFile(new File(pathFileName));
    SevenZArchiveEntry entry = sevenZFile.getNextEntry();

    try {

        while (entry != null) {

            if ("deudores.txt".equals(entry.getName())) {

                Instant now = Instant.now();
                LOG.info("\tunzipping: {} -> {}/{}", pathFileName, saveFilePath, entry.getName());

                byte[] buffer = new byte[1024];
                File newFile = newFile(new File(saveFilePath), entry.getName());
                FileOutputStream fos = new FileOutputStream(newFile);
                int len;
                while ((len = sevenZFile.read(buffer)) > 0) {
                    fos.write(buffer, 0, len);
                }
                fos.close();
                LOG.info("\tunzipping done, took {} secs", now.until(Instant.now(), ChronoUnit.SECONDS));
                return saveFilePath+"/"+entry.getName();
            }
            entry = sevenZFile.getNextEntry();
        }
    } finally {
        sevenZFile.close();
    }
    return null;
}


 public File newFile(File destinationDir, String name) throws IOException {
    File destFile = new File(destinationDir, name);

    String destDirPath = destinationDir.getCanonicalPath();
    String destFilePath = destFile.getCanonicalPath();

    if (!destFilePath.startsWith(destDirPath + File.separator)) {
        throw new IOException("Entry is outside of the target dir: " + name);
    }

    return destFile;
}
我只得到第一个1GB

有什么建议/替代方案吗?交换到另一个库不是问题

解决了。。。缓冲区上的迭代错误。