This content has been marked as final. Show 3 replies
977295 wrote:You may want to try:
InputStream is = cl.getResourceAsStream("/resources/" + filename);
Anyone knows why? And why the exact same code works if I remove "/resources/" and put "tiles.txt" next to the class file? For the record. I am able to load image files from the same subfolder.
Using the classloader the search is already relative to the root of the classpath.
InputStream is = cl.getResourceAsStream("resources/" + filename);
And of course you get a NullPointer because the InputStream reference returned contains null, but your code assumes it is not. Which is fine, that's an assumption you can make as soon as you fix the minor path thing.
Hi and thanks for the reply.
I tried without the leading slash, but getting the same negative result:\
Could it be security related? Wouldnt think so, as I'm only trying to access files within the rar. But cant think of anything else, and I'm not very experienced with applets.
Please post the result of jar tvf xxx.jar /resources/<file name>.