| Author |
Jar File Resources
|
Gregg Bolinger
Ranch Hand
Joined: Jul 11, 2001
Posts: 15230
|
|
My application is a JAR file and I am needing to get a group of resources all at one time with specifically specifying the file names. I know how to get a single resources, for example. getClass().getClassLoader().getResource("") but I have a directory full of images and I need to get all the image names. So basically, if I were to do this outside of a JAR file I would do something like: And that would get all my file names in the File[] array. Is there an easy method of doing the same thing from within a JAR? You can't get File objects when your application is running from a JAR because it will look outside the JAR file for those resources. Thanks.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56534
|
|
|
Although I've never used it, perhaps the classes in the java.util.jar package would help you inspect the contents of the jar file.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
Hi Gregg, there is a piece of code over at the Java Almanac that shows you how to list the entries of your JAR file. With that, you can get your images back.
|
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
|
 |
Fisher Daniel
Ranch Hand
Joined: Sep 14, 2001
Posts: 582
|
|
Hi, I dont know if it is proper for your case. I think you can use classes in package java.util.zip.* to get name and the content of your JAR file. Correct me if I am wrong thanks daniel
|
 |
Srinivasa Raghavan
Ranch Hand
Joined: Sep 28, 2004
Posts: 1228
|
|
Hi hope this help's u ... [ November 07, 2004: Message edited by: srini vasan ]
|
Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
|
 |
 |
|
|
subject: Jar File Resources
|
|
|