I'm trying to have my application load a resource (binary file) transparently:
If the file exists under the current directory, open it.
If not, try looking in the current JAR file if applicable.
If not, try looking in other JAR files. (This is optional and I don't mind explicitly specifying which JAR files.)
So far I know of File
which opens a local file and ClassLoader
which has getResource*
for JAR contents.
Is there a class which combines the two? If not, how should I go about writing it myself? Should I write a ClassLoader
which also checks the local filesystem? Using File
? (I'm very unfamiliar with Java and don't even know what's a good type to return. InputStream
?)
Thanks
P.S. By "file" I mean "path", e.g. "data/texture1.png".