0

I have some default configuration files inside my application jar that I would like to save to the file system if they don't already exist. I would like it to keep the directory structure too. Example:

Jar file
-configs/
    -main-config.cfg
    -another-file.txt
    -stuff/
        -another-file.cfg
-com/
-META-INF/

I would like the contents of configs/ to be mirrored to the file system, including the subfolder.

Leagsaidh Gordon
  • 1,641
  • 5
  • 19
  • 28
  • Possible duplicate: http://stackoverflow.com/questions/981578/how-to-unzip-files-recursively-in-java – rlegendi Jun 07 '12 at 13:14

1 Answers1

1

Use JarFile.entries to get an enumeration of all of the entries in your Jar file.

Jeffrey
  • 44,417
  • 8
  • 90
  • 141
  • How would I check that they are in the directory I want, etc? I've barely used the zip/jar packages before. – Leagsaidh Gordon Jun 07 '12 at 13:22
  • @SeanGordon You can get the [name](http://docs.oracle.com/javase/7/docs/api/java/util/zip/ZipEntry.html#getName()) of the entry and see if it [begins](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#startsWith(java.lang.String)) with the directory you want. – Jeffrey Jun 07 '12 at 14:49