tags:

views:

55

answers:

1
+5  A: 

Resources in a .jar file are not files in the sense that the OS can access them directly via normal file access APIs.

And since java.io.File represents exactly that kind of file (i.e. a thing that looks like a file to the OS), it can't be used to refer to anything in a .jar file.

A possible workaround is to extract the resource to a temporary file and refer to that with a File.

Note that generally APIs that try to handle files should be written to handle InputStream/OutputStream as well to allow this kind of operations to suceed.

Joachim Sauer
Yeah, I didn't write the API or else I would have done that. I have already debated the temporary file solution and if that is the only option I'd rather use config files that other developers can set up where to put the files.
Corv1nus