指向虚拟文件系统的java URI

时间:2017-06-05 21:53:39

标签: java zip uri nio jimfs

我需要在java中为虚拟文件系统(jimfs)创建一个URI。我需要这样做,以便我可以将文件添加到zip存档(通过将zipfile定义为文件系统)。如何将URI变量指向下面的虚拟文件系统? (或者,如果它不起作用,还有另一种方法可以做到这一点)

filesystem = Jimfs.newFileSystem(Configuration.unix())
   URI zipDisk = zipFile.toUri()
        FileSystems.newFileSystem(zipDisk, zip_properties).withCloseable { FileSystem zipfs ->
            Path ZipFilePath = zipfs.getPath(fileToZip.getFileName().toString())                //Define the file as it will exist in the zipfile
            Files.copy(fileToZip,ZipFilePath, StandardCopyOption.REPLACE_EXISTING);
        }

此代码生成"可能没有路径,查询或片段"错误。

0 个答案:

没有答案