首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jar中文件的AsynchronousFileChannel

jar中文件的AsynchronousFileChannel
EN

Stack Overflow用户
提问于 2017-08-29 23:01:37
回答 1查看 99关注 0票数 3

有没有办法打开存储在类路径上jar中的文件的AsynchronousFileChannel

如果我尝试直接创建一个Path,我会得到FileSystemNotFoundException。如果我先创建文件系统:

代码语言:javascript
复制
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的解决方案。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-09-10 22:54:20

JDK中的zip文件系统提供程序不支持异步I/O,这就是抛出UOE的原因。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45942456

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档