Hi all. Not sure where else to post this… so this seemed the best place.
Anyway. What I need to to do here is list files from a directory called “images” inside a JAR file. Whenever I didn’t have my application in a JAR, I used the following:
File list[] = (new File("images")).listFiles(filter);
(filter is my FileFilter to return only PNG images)
However, I can’t use new File(“images”) in a JAR because it would just think I’m trying to access the directory outside the JAR. So I need to somehow create a File from this URL:
URL dir = Thread.currentThread().getContextClassLoader().getResource("images");
And I obviously need a File object because nothing else has the method listFiles() (that I know of). I’ve spent the last hour searching and trying everything I know. I even tried using the following:
URL dir = Thread.currentThread().getContextClassLoader().getResource("images");
File list[] = (new File(URI.create(dir.toString()))).listFiles(filter);
But it tells me that it’s not hierarchical. What can I do here?
Thanks,
Jamison