是否可以使用jar xf提取空文件夹?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了是否可以使用jar xf提取空文件夹?相关的知识,希望对你有一定的参考价值。

我在脚本中使用jar xf file解压缩一个zip文件,该文件也包含空文件夹,但不提取空文件夹。是否可以使用jar xf file提取空文件夹?

编辑:事实上,正如Mike Slinn在答案中指出的那样。我现在已经注意到,当我使用另一个不是由我自己创建的zip文件时,空文件夹实际上变成了空文件。这些zip文件中的空文件夹有什么区别?我使用Windows 10和JDK 1.8.0_144 64位。

答案

是。这是证明:

$ mkdir empty # create an empty directory

$ jar -cf ~/junk.jar empty ./cache # add the empty directory and other directory to a new jar

$ jar -tf ~/junk.jar # list the contents of the jar
META-INF/
META-INF/MANIFEST.MF
empty/
cache/
cache/ssh/
cache/ssh/hostkeys

$ mkdir blah # make a temporary directory

$ cd blah # move to the temporary directory

$ jar -xf ~/junk.jar # extract the jar into the temporary directory

$ l empty # verify that the "empty" directory exists and is actually empty
total 8
drwxrwxr-x 2 mslinn mslinn 4096 Dec 24 19:42 ./
drwxrwxr-x 5 mslinn mslinn 4096 Dec 24 19:43 ../

以上是关于是否可以使用jar xf提取空文件夹?的主要内容,如果未能解决你的问题,请参考以下文章

Android课程---Android Studio使用小技巧:提取方法代码片段

从 .jar 文件重新创建项目

vue.js 2 - 将单个文件组件的 html 片段提取到独立文件中

在使用 IVY 的项目中包含来自文件系统的项目 JAR 无法提取源代码和 javadoc

将 .zip 存档解压缩到 .jar 文件

由于没有 Java 代码或资源,如何使用空的 javadoc jar(或空的源 jar)将工件上传到 Maven Central?