我试图阅读ZIP文件的内容。
在创建FileSystem时,我得到 FileSystemAlreadyExistsException ,因为受影响的zip文件已经存在。
即使我在创建文件系统时指定{"创建"," false"}
代码(改编自http://fahdshariff.blogspot.com.es/2011/08/java-7-working-with-zip-files.html):
private static FileSystem createZipFileSystem(String zipFilename,
boolean create)
throws IOException {
// convert the filename to a URI
final Path path = Paths.get(zipFilename);
final URI uri = URI.create("jar:file:" + path.toUri().getPath());
final Map<String, String> env = new HashMap<>();
String value="false";
if (create) {
value="true";
}
env.put("create", value);
return FileSystems.newFileSystem(uri, env);
}
电话:
FileSystem zipFileSystem = createZipFileSystem(zipFilename, false);