簡體   English   中英

"org.tukaani.xz.CorruptedInputException:在 java 中提取 7z 存檔文件時壓縮數據損壞"

[英]org.tukaani.xz.CorruptedInputException: Compressed data is corrupt while extracting 7z archive File in java

獲取 org.tukaani.xz.CorruptedInputException:提取 7z 文件時壓縮數據損壞錯誤。 我正在使用 common-compress-1.21.jar 和 xz-1.9.jar。這是我的代碼

    File f = new File("/home/local/Documents/7zFile/7zFile.7z");
    InputStream inputStream;
    ArchiveEntry entry = null;
    try {
        inputStream = new FileInputStream(f);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (!inputStream.markSupported()) {
        inputStream = new BufferedInputStream(inputStream);
    }
       
    inputStream.mark(Integer.MAX_VALUE);
    byte[] inputData = IOUtils.toByteArray(inputStream);
    inputStream.reset();
    SeekableInMemoryByteChannel channel = new              
                                   SeekableInMemoryByteChannel(inputData);        
    sevenZFile = new SevenZFile(channel);
            while ((sevenZFile!=null && (entry = sevenZFile.getNextEntry()) != null)) {
                             System.out.print(entry.getName());                                  
            }

LZMA 數據具有流結束標記。 這樣的 .7z 文件是有效的,但很少見。 XZ for Java 1.9 特別添加了一個特性。 請找到此鏈接以更好地理解。 https://issues.apache.org/jira/browse/COMPRESS-591

https://sourceforge.net/p/lzmautils/discussion/708858/thread/822d80d5ea/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM