ZIP文件的ZipEntry

时间:2014-03-17 12:57:15

标签: java

我正在尝试确定zipEntry(zip文件)是否是目录,但测试返回false。

//entryName is the name of a directory inside of the zip file
File file = new File (entryName);
if(file.isDirectory()){ ...}

1 个答案:

答案 0 :(得分:0)

使用Java 7提供的新ZIP文件系统:

final Path path = Paths.get("/path/to/my.zip");
final String uri = "jar:" + path.toUri().toString();

try (
    final FileSystem fs = FileSystems.newFileSystem(URI.create(str),
       Collections.<String, String>emptyMap(), null);
) {
    return Files.isDirectory(fs.getPath("/path/into/zip/file"));
}