Is there a way to open an AsynchronousFileChannel
for a file stored in a jar on the classpath?
If I try creating a Path
directly, I get FileSystemNotFoundException
.
If I create the file system first:
URI uri = ...; //get the URI of a file in a jar
String[] array = uri.toString().split("!");
FileSystem fs = FileSystems.newFileSystem(URI.create(array[0]), Collections.emptyMap());
Path path = fs.getPath(array[1]);
AsynchronousFileChannel ch = AsynchronousFileChannel.open(path);
It explodes with UnsupportedOperationException
:(
Is there any way to achieve this?
My project is Spring (and using ClassPathResource
for this), so a Spring specific solution works.
The zip file system provider in the JDK does not support asynchronous I/O so this is why UOE is throw.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With