Maintain file permissions when extracting from a zip file using JDK 5 api

后端 未结 4 1616
深忆病人
深忆病人 2020-12-06 16:15

I am using java.util.Zip and java.util.ZipEntry to successfully extra a zip file\'s contents to disk. I would like to maintain the file permissions set when extracting on a

4条回答
  •  粉色の甜心
    2020-12-06 16:55

    Essentially, you can't STORE (unix) file permissions in Zip/Jar files, so you can't preserve them when extracting your jar (they were lost when the jar was created to begin with). See this question: creating a jar file - preserving file permissions

    If you need the file permissions preserved in the archive and restored when extracting, you need to consider the alternative .tar or .tar.gz / .tar.bz2 format, which is also natively supported by most Java build tools (Ant, Gradle, Maven...)

提交回复
热议问题