Reputation: 2350
I am working with Spring boot jar and I have got nested jars in my structure. I am trying to read the raw bytes from the class file. I would like to get InputStream from following URL
"jar:file:/D:/work/dev/target/first.jar!/BOOT-INF/lib/second.jar!/a/b/c/Data.class"
I have tried
InputStream i = new URL( str ).openStream();
But this does not work ( FileNotFoundException ). I do not want to use spring-boot's API. Since that URL looks pretty standard I am hoping that there should be a way to achieve this.
Upvotes: 0
Views: 620
Reputation: 10154
Is "second.jar" in the classpath?
If yes, use the Classloader.getResourceAsStream()
For example:
Thread.currentThread().getContextClassLoader().getResourceAsStream("a/b/c/Data.class")
Upvotes: 1