Getting org.tukaani.xz.CorruptedInputException: Compressed data is corrupt error while extracting 7z file. i am using common-compress-1.21.jar and xz-1.9.jar.here is my code
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());
}
stackTrace of error
org.tukaani.xz.CorruptedInputException: Compressed data is corrupt
at org.tukaani.xz.LZMAInputStream.read(Unknown Source)
at org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:88)
at org.apache.commons.compress.utils.IOUtils.copyRange(IOUtils.java:330)
at org.apache.commons.compress.utils.IOUtils.copyRange(IOUtils.java:301)
at org.apache.commons.compress.utils.IOUtils.readRange(IOUtils.java:350)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.readEncodedHeader(SevenZFile.java:706)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.initializeArchive(SevenZFile.java:544)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.readHeaders(SevenZFile.java:474)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.<init>(SevenZFile.java:343)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.<init>(SevenZFile.java:255)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.<init>(SevenZFile.java:183)
at org.apache.commons.compress.archivers.sevenz.SevenZFile.<init>(SevenZFile.java:167)
in this line sevenZFile = new SevenZFile(channel);
its throwing error.
i have created 7z archive file in ubuntu OS for this file its throwing exception, the 7z archive which i created online website its working fine. is there any issue with ubuntu? and how to fix this? Thanks in advance.
The LZMA data has an end of stream marker. Such .7z files are valid but quite uncommon. XZ for Java 1.9 added a feature specifically. please find this link for better understanding. https://issues.apache.org/jira/browse/COMPRESS-591
https://sourceforge.net/p/lzmautils/discussion/708858/thread/822d80d5ea/