Getting org.tukaani.xz.UnsupportedOptionsException: Uncompressed size is too big error while trying to decode LZMA compress xls file. Whereas non LZMA files getting unpack/decode without any issue. Both the cases same xls file being compressed.
I am using Apache commons compress and org.tukaani.xz.
sample code for reference
package com.concept.utilities.zip;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream;
public class ApacheComm {
public void extractLZMAZip(File zipFile, String compressFileName, String destFolder) {
ZipFile zip = null;
try {
zip = new ZipFile(zipFile);
ZipArchiveEntry zipArchiveEntry = zip.getEntry(compressFileName);
if (null != zipArchiveEntry) {
String name = zipArchiveEntry.getName();
// InputStream is = zip.getInputStream(zipArchiveEntry);
InputStream israw = zip.getRawInputStream(zipArchiveEntry);
LZMACompressorInputStream lzma = new LZMACompressorInputStream(israw);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != zip)
ZipFile.closeQuietly(zip);
}
}
public static void main(String[] args) throws IOException {
ApacheComm c = new ApacheComm();
try {
c.extractLZMAZip(new File("H:\\archives\\rollLZMA.zip"), "roll.xls", "H:\\archives\\");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Error
org.tukaani.xz.UnsupportedOptionsException: Uncompressed size is too big
at org.tukaani.xz.LZMAInputStream.initialize(Unknown Source)
at org.tukaani.xz.LZMAInputStream.<init>(Unknown Source)
at org.apache.commons.compress.compressors.lzma.LZMACompressorInputStream.<init>(LZMACompressorInputStream.java:50)
at com.concept.utilities.zip.ApacheComm.extractLZMAZip(ApacheComm.java:209)
at com.concept.utilities.zip.ApacheComm.main(ApacheComm.java:224)
Am I missing something? Is there any other way I can decode zip file with compression method = LZMA