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
2010-02-03 14:31:42