jar - 按路径从 Jar 中获取文件

标签 jar path classloader nio java-7

我在复制 jar 中的文件时遇到问题:

URI ink2_1 = this.getClass().getClassLoader().getResource("Masi_INK2.bmp").toURI();
...
Files.copy(Paths.get(sourceFile1), Paths.get(IAIOutputFile+requestId+"_INK1.bmp"));

路径无法解析路径

15:43:11,505 INFO  [MainFake] searching for jar:file:/C:/workspace/clone/Tools/DummySimulator/DummySimulator-1.0-SNAPSHOT.jar!/Masi_INK2.bmp
15:43:11,505 INFO  [MainFake] Exception in thread "main" java.nio.file.FileSystemNotFoundException
        at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
        at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
        at java.nio.file.Paths.get(Unknown Source)
        at com.example.MainFake.processImages(MainFake.java:101)

最佳答案

This bug仍然存在于 7u25 中。

关于jar - 按路径从 Jar 中获取文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17550870/

相关文章:

java - 调试 eclipse/jdt jar 文件中的类方法

java - 如何在 `gradle.build`中强制使用版本的特定jar?

algorithm - All 对图形上的所有路径

java - 为什么不允许未签名的小程序创建自定义类加载器?

annotations - 字节码注入(inject)发生在哪里?

java - 如何在项目中使用 .jar 文件并在没有 IDE 的情况下编译它?

maven-2 - 将 Maven 生成的站点添加到生成的包中

java - Play Framework 中的完整目标/当前 URL?

laravel - 将 laravel 项目从 VSTS 发布到 Azure 到正确的文件夹

java - 来自扩展类加载类的类转换异常