zip and unzip in java

后端 未结 2 1539
自闭症患者
自闭症患者 2021-01-29 12:38

I know that it is an easy task, but after changing my code it stopped working and I can\'t get it back! I use two functions to zip and unzip, even though what it actually does i

2条回答
  •  半阙折子戏
    2021-01-29 13:00

    I don't know if this is your problem or not, but it is generally good practice to close each zip entry after you finish writing.

    See ZipOutputStream.closeEntry().

    In the code that you show, the very last entry in the zip would not be closed. You also don't show where you close the JarOutputStream itself. This could be causing you to create invalid zip files, which would have errors when they are read back in using your other method.

提交回复
热议问题