Protocol for loading resources from jar
I'm writing a program that, among other things, displays html documents. These documents are often quite image-heavy, and downloading all the resources can take some time. I'm now planning on bundling some of the most commonly used resources directly into my JAR file, and want it to be easy to reference these from the external documents: e.g. instead of
I could use
or whatever. (note: only one slash shown in examples because forum doesn't like me posting links).
Note that I may not know the location of the jar file, or maybe not even the jar file it's in. I think this should be ok, though -- I'd want to do essentially the same thing that SomeClass.getClassLoader().getResource("/org/company/...") would do.
Apparently there's some way of creating a custom protocol, but I haven't really understood the documentation on this. Can anyone provide an example of this in action? Or, if that's not the right line of thought, some other solution?
Thanks so much,