有没有办法打开存储在类路径上jar中的文件的AsynchronousFileChannel?
如果我尝试直接创建一个Path,我会得到FileSystemNotFoundException。如果我先创建文件系统:
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);它使用UnsupportedOperationException进行分解:(
有什么方法可以做到这一点吗?
我的项目是Spring (并为此使用了ClassPathResource ),所以有一个特定于Spring的解决方案。
发布于 2017-09-10 22:54:20
JDK中的zip文件系统提供程序不支持异步I/O,这就是抛出UOE的原因。
https://stackoverflow.com/questions/45942456
复制相似问题