3

I zipped a bunch of IIS log files on a windows 2008 r2 vm by selecting them in Windows Explorer and then using the Send To -> Compressed zipped folder.

I wrote different programs in scala using java.util.ZipFile, zip4j and apache commons compress library.

zip4j returns: Exception in thread "main" net.lingala.zip4j.exception.ZipException: Unknown compression method

commons compress returns: org.apache.commons.compress.compressors.CompressorException: No Compressor found for the stream signature.

java.util.Zip returns: java.util.zip.ZipException: invalid compression method

What is so special about these zip files that none of these methods can unzip them?

How can I unzip them using the JVM libraries?

As an example I used this code: https://stackoverflow.com/a/10634536/832783 to unzip one of the files and it returned the invalid compression method exception.

These are the first 16 bytes in the archive: enter image description here

boggy
  • 3,674
  • 3
  • 33
  • 56

1 Answers1

4

According to the header information (from the 16 bytes from your post), this entry in the zip file was encrypted using Deflate64. Deflate64 is not to be confused with Deflate compression. Deflate64 is PKWare trademark (PKWare are the maintainers of zip format) and is an enhanced version of Deflate compression algorithm. According to this question on superuser, and this PR on github, Windows uses Deflate64 if the file size is greater than 2GB. zip4j and jdk's zip utility does not support Deflate64 yet, but commons-compress version 1.16 has support for Deflate64. You can probably try using the latest version of commons-compress to unzip your zip file.

Edit: Alternatively, if you have the option, you can try to create the zip file with some other tool (7zip, zip4j, etc). Then you don't have to deal with Deflate64, which makes your zip files compatible with other tools.

  • It is true that the zip file contains several log files, which in total, unzipped, have around 16gb. Each file has between 100 and 300 mb. The archive has approx. 1.2GB. – boggy Dec 21 '19 at 22:56
  • 1
    Well, to be hones, I simply cannot believe that the JDK has not covered this and that it handles out of the box. From a white box perspective, on java.util.zip I should not care if it is Deflate64 or Deflate and just simply use the API. – admirm Jan 12 '21 at 18:36