【发布时间】:2014-08-06 17:16:04
【问题描述】:
我在使用 URI 类时遇到问题。
我可以在 c:\ 中创建一个 zip 文件,代码如下:
// Properties for archive file we're creating
Map<String, String> archiveProperties = new HashMap<>();
archiveProperties.put("create", "true");
archiveProperties.put("encoding", "UTF-8");
URI archiveLocation = URI.create("jar:file:/" + "my.zip");
// Create archive
FileSystem archive = FileSystems.newFileSystem(archiveLocation, archiveProperties);
但如果您愿意的话,我真的希望将 zip 文件从当前工作目录中创建一个目录。我尝试了很多东西,包括:
// Properties for archive file we're creating
Map<String, String> archiveProperties = new HashMap<>();
archiveProperties.put("create", "true");
archiveProperties.put("encoding", "UTF-8");
URI archiveLocation = URI.create("jar:file:../" + "my.zip");
// Create archive
FileSystem archive = FileSystems.newFileSystem(archiveLocation, archiveProperties);
但我要么得到一个异常,在这种情况下 URI 不是分层的,要么它继续在 c:\
中创建【问题讨论】: