I have created a Zip file on a JimFS FileSystem
instance. I would now like to read the Zip using the Java FileSystem
API.
Here is how I create the FileSystem
:
final FileSystem zipFs = FileSystems.newFileSystem( source, // source is a Path tied to my JimFS FileSystem null);
However, this throws an error:
java.nio.file.ProviderNotFoundException: Provider not found
Interestingly, the code works with the default FileSystem
.
- What does this error mean?
- How should I create my Zip
FileSystem
?
Advertisement
Answer
This is not supported before JDK 12 via that specific constructor (Path, ClassLoader
)
This was fixed in JDK12, with commit 196c20c0d14d99cc08fae64a74c802b061231a41
The offending code was in ZipFileSystemProvider in JDK 11 and earlier:
if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); }