tutorials icon indicating copy to clipboard operation
tutorials copied to clipboard

ZIP-tutorial - unzipping on MACOS fails

Open FlutterCrypto opened this issue 4 years ago • 2 comments

First of all - thanks for your Java ZIP tutorial on https://www.baeldung.com/java-compress-and-uncompress.

I run the demo and I could zip multiple files but when trying to unzip the file on MACOS it fails with "error 79".

I think one line of code is missing in https://github.com/eugenp/tutorials/blob/master/core-java-modules/core-java-io/src/main/java/com/baeldung/zip/ZipMultipleFiles.java (I didn't test it but I believe the error will occur as well on ZipDirectory.java and ZipFile.java).

Old code (just the important part):

         while ((length = fis.read(bytes)) >= 0) {
            zipOut.write(bytes, 0, length);
        }
        fis.close();

New code (insert just one extra line of code to fix the problem):

        while ((length = fis.read(bytes)) >= 0) {
            zipOut.write(bytes, 0, length);
        }
        zipOut.closeEntry();
        fis.close();

Greetings Michael

FlutterCrypto avatar Feb 18 '22 23:02 FlutterCrypto

Thanks for the feedback @FlutterCrypto! We'll take a look into this.

kwoyke avatar Mar 10 '22 12:03 kwoyke

Tested on apple M2 and working correct.

suhitk001 avatar Apr 17 '22 10:04 suhitk001

@FlutterCrypto, we are unable to reproduce the problem. Can you provide more details on how to replicate the issue?

dkapil avatar Aug 25 '22 16:08 dkapil