Add a means to convert a URI to a JimfsPath
See original GitHub issueThere is no obvious way to convert a URI into a JimfsPath
. Normally, one could use fs.provider().getPath(uri)
, but this is not implemented by JimfsFileSystemProvider
; instead, it throws an exception stating:
This method should not be called directly; use Paths.get(URI) instead.
Which is funny, since on #12 @cgdecker (main contributor to the project?)
strongly recommends not using
Paths.get
I would’ve used JimfsFileSystem.toPath(URI)
, but the entire class is set to the package-private access modifier (why the hell?).
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Convert file: Uri to File in Android - Stack Overflow
Uri object which is named uri and created exactly as in the question, uri.toString() returns a String in the format "file:///mnt/sdcard/myPicture.jpg" , whereas ......
Read more >java.nio.file.Path.getFileSystem java code examples - Tabnine
This implementation creates a FileSystemResource, applying the given path * relative to the path of the underlying file of this resource descriptor.
Read more >Java Examples for java.nio.file.ProviderMismatchException
This java examples will help you to understand the usage of java.nio.file.ProviderMismatchException. These source code samples are taken from different open ...
Read more >Get File from URI - CommonsWare
I'm having a hard time getting a File's path from a URI. ... There are scenarios where that is needed (e.g., an import...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@o2themar You’re getting that exception because you’re calling
FileSystems.newFileSystem(URI, Map)
with a URI with the schemejimfs
. That tells Jimfs to create a new Jimfs file system, not a zip file system, and the URI for a Jimfs file system isn’t allowed to have a path, query or fragment (because they don’t make sense in that context).The scheme for a zip file system is
jar:<underlying file system scheme>
, so in the case of a file in a Jimfs file system,jar:jimfs
. So your code would probably work if you just pass"jar:" + zipURI.getScheme()
as the scheme for your new URI.That said, you should be able to get a zip file system for a Jimfs path by just calling
FileSystems.newFileSystem(Path, Map)
:@cgdecker I got to review this issue again with the recent activity, and I’m appalled at my previous behavior. I apologize for the demanding and combative tone. I really appreciate the work and effort you put into this!