Search code examples
jarpathclassloaderniojava-7

File from Jar by paths


I have a problem with copying file that is in a jar:

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

Path is not able to resolved by Paths

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)

Solution

  • This bug is still present in 7u25.