I would like to better understand what to expect when I use a .getFile() or .getPath() on a Url object. I am noticing that for resources packed in a jar, there may be an "!" in the file
string separating the jar from the resource part. Also, at the beginning, there may be "file:/" preceding the "c:/Documents%20and%20Settings/Phil/..." etc. At least, this is what occurs on my Windows XP OS, from a Jar. The file string returned from within Eclipse
IDE is different as well.
My understanding is that the best way to pack content files with a Jar, and then load this content, is to use the class.getResource(relativeFileName) which returns a Url or class.getResourceAsStream(relativeFileName) which returns an InputStream. Both work for my current project, but there is an object I wish to create that has a requirement for a working file name in its constructor. (I am a bit wary about going into this code--which I did not write--to try and figure out a way to redo the constructor to accept a URL.)
I can certainly do various string ops on the strings I get from .getFile(), (e.g., convert %20 to " ", strip out the "file:/" or "!") but it would be nice to know more about the range of things to expect. Or, it would be nice to know if there is a better way to determine an absolute, full path file name for a resource.
Any suggestions where I could learn more about this? I have read through the
Java Tutorials "Custom Networking", "Working with URLs" section and don't see the issue addressed there.
Many thanks!