我需要在 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);
}
此代码产生“可能没有路径、查询或片段”错误。