srikanth-lingala / zip4j

A Java library for zip files and streams
Apache License 2.0
2.01k stars 307 forks source link

0 KB size ZIP file is created with net.lingala.zip4j:zip4j:2.11.2 in Android #481

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hi,

I have used net.lingala.zip4j:zip4j:2.11.2 gradle dependency in android project to create a zip file. The created Zip file will contain a folder, folder with in the main folder. The final folder will contain a TXT file.

Zip file instance created using below approach.

new ZipFile(mFileName,password.toCharArray());

Once I copied the logs, Observed 0 KB zip file created. When I try to extract the 0 KB ZIP file. It is giving error "The archive is either in unknown format or damaged"

I have used below code to create the ZIP file from files.

The issue is not always. It is observed randomly.

ZipParameters zipParameters = new ZipParameters(); zipParameters.setEncryptFiles(true); zipParameters.setEncryptionMethod(EncryptionMethod.ZIP_STANDARD); ZipFile zipFile = null; try { zipFile = new ZipFile(mFileName,password.toCharArray()); zipFile.addFiles(filesToAdd,zipParameters); }

Thanks IN advance for your answer.

srikanth-lingala commented 1 year ago

Duplicate of #482