I have successfully obtained a Url from a resource. But url.getFile() returns different things in different contexts. For example, in my Eclipse IDE:
/C:/Documents%20and%20Settings/Phil/workspace/Fivefold/bin/com/adonax/fivefold/audio/elders.ogg
If I’m running the same code from a Jar:
file:/C:/Documents%20and%20Settings/Phil/Desktop/Java/fivefold/ffogg.jar!/com/adonax/fivefold/audio/elders.ogg
Note the presence of the “!” in this one.
So, it is possible to do the following which works in both contexts (though it really feels like a kluge):
String s = s.replace("%20", " ");
s = s.replace("!", "");
s = s.replace("file:", "");
s = s.substring(1);
But I sure would like to know either or both:
- what the heck is going on with getFile(), why is it adding these things and what will happen when I try to do this in another OS or as an Applet?
- is there a better way to get a filename for a working “resource” that is in a Jar?
Reason for question: there is a function in JCraft’s JOrbis that allows one to obtain a frame count but I can only make it work for VorbisFile objects created with a filename string. When I make a VorbisFile object with an InputStream, it decides the file is not “seekable”. (I would have to dig deeper into the JOrbis code to find out why this is.) If I could get that framecount another way, that would make the above question moot, but still kind of interesting to me. The whole Jar/File/Resource complex has always been a toughie.
Many thanks!