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

问题描述 投票:0回答:1

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

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

jar directory extract unzip
1个回答
1
投票

是。这是证明:

$ 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 ../
© www.soinside.com 2019 - 2024. All rights reserved.