2
有沒有辦法打開AsynchronousFileChannel
存儲在類路徑上的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
:(
有什麼辦法來實現這一爆炸
我的項目是春季(以及使用ClassPathResource
此),所以Spring的具體解決方案有效