Java jar中文件的异步FileChannel
有没有办法为类路径上存储在jar中的文件打开Java jar中文件的异步FileChannel,java,spring,classpath,nio,channel,Java,Spring,Classpath,Nio,Channel,有没有办法为类路径上存储在jar中的文件打开异步文件通道 如果我尝试直接创建路径,我会得到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]), Collecti
异步文件通道
如果我尝试直接创建路径
,我会得到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);
它会随着不支持操作异常而爆炸:(
有没有办法做到这一点
我的项目是Spring(并为此使用了ClassPathResource
),因此Spring特定的解决方案是可行的。JDK中的zip文件系统提供程序不支持异步I/O,所以这就是抛出UOE的原因