// Initiate ZipFile object with the path/name of the zip file.
ZipFile zipFile = new ZipFile("c:\\ZipTest\\CreateSplitZipFileFromFolder.zip");
// Initiate Zip Parameters which define various properties such
// as compression method, etc.
ZipParameters parameters = new ZipParameters();
// set compression method to store compression
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
// Set the compression level. This value has to be in between 0 to 9
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
// Create a split file by setting splitArchive parameter to true
// and specifying the splitLength. SplitLenth has to be greater than
// 65536 bytes
// Please note: If the zip file already exists, then this method throws an
// exception
zipFile.createZipFileFromFolder("C:\\ZipTest", parameters, true, 10485760);
I copied this from the sample code for using zip4j, specifically the file named CreateSplitZipFileFromFolder.java
the problem is that, even if I set to true the third parameter of createZipFileFromFolder
, it would still return false when I call the method ZipFile.isSplitArchive()
from grepcode, it appears it just sets the ZipModel
object the boolean flag that I set, but I get a different value. any ideas why this is?
Is your generated ZIP file larger than splitLength
bytes (10485760 in your example)? From the documentation of splitLength for createZipFile
if archive has to be split, then length in bytes at which it has to be split
I assume a split Zip file will only be created if it gets larger than that size.