How to create Uncompressed Zip archive in Java

前端 未结 3 1906
心在旅途
心在旅途 2020-12-30 00:55

I am using the Zip utility package of Java and wanted to know how to create a zip file with no compression at all. Setting the level to 0 doesn\'t help. Is this right?

3条回答
  •  天命终不由人
    2020-12-30 01:29

    You need to use the STORED method, but this requires that you set the size, compressedSize and crc32 properties of the corresponding ZipEntry before you can call putNextEntry on the ZipOutputStream. You can precompute the CRC-32 by using a Crc32OutputStream.

提交回复
热议问题