directories in a zip file when using java.util.zip.ZipOutputStream

后端 未结 6 1615
北荒
北荒 2020-12-04 13:40

Lets say I have a file t.txt, a directory t and another file t/t2.txt. If I use the linux zip utility \"zip -r t.zip t.txt t\", I get a zip file with the following entries i

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 14:13

    Like others said here to add empty directory add "/" to the directory name. Pay attention NOT to add File.separator (equals to "\") which actually add an empty file to the zip.

    It took me a while to understand what was my mistake - hope I save other some time...

提交回复
热议问题