java URI pointing to virtual filesystem

我怕爱的太早我们不能终老 提交于 2019-12-12 06:23:47

问题


I need to create a URI to a virtual filesystem (jimfs) in java. I need to do this so that I can add files to a zip archive (by defining the zipfile as a filesystem). How can I point the URI variable below to my virtual filesystem? (or, if that won't work, is there another way to do this)

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);
        }

This code produces a "may not have a path, query, or fragment" error.

来源:https://stackoverflow.com/questions/44378292/java-uri-pointing-to-virtual-filesystem

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!