Finding files in jars

Hello,

I have a problem with finding xml files in my program.

Here is what I want to do:

In my project there are some xml files under a certain file structure, say "src/main/data".

These files determine the behaviour of some UI masks and define database objects.

The files are read and parsed on startup. I search only src/main/data on the filesystem for files.

To extend the functionality of my program I want to be able to include a jar file containing the same path. Under this path there are more xml files.

This has the advantage that you can configure your program by adding/removing jars to your classpath.

Here is the problem.

I'm able to manage to read the filessystem and search for xml data.

I'm not able to do this with jars. Originally I thought if there is the same path in a jar, the files in this jar will be somehow "mapped" to my project.

This is obviously wrong.

How can I find certain files in jars I dont know the name from? All I know is the path.

Do you understand what I try to say?

Do you have a solution or any hint where I can go and take a look?

Thank you very much!

Stefan

[1206 byte] By [Stefan_Ulma] at [2007-11-26 15:21:46]
# 1
May be the following will solve your problem.1. Open the jar file with Winzip.2. Select sort by type.3. You can find the files of types separately.
GVReddya at 2007-7-8 21:36:43 > top of Java-index,Java Essentials,Java Programming...
# 2
Thank you for your answer.I dont think it will solve my problem, because I want to do it in a running java program.Thanks anyway.
Stefan_Ulma at 2007-7-8 21:36:43 > top of Java-index,Java Essentials,Java Programming...
# 3
hmnn I can't remember if the java.util.zip package can be used to open a jar file, I would assume it ought to be able to do that. If so, just get the listing of contents from the jar file and extract the xml files. http://java.sun.com/j2se/1.5.0/docs/api/java/util/zip/ZipFile.html
cjmosea at 2007-7-8 21:36:43 > top of Java-index,Java Essentials,Java Programming...