Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java unzip fild path problems

Status
Not open for further replies.

crmayer

Programmer
Nov 22, 2002
280
US
I am not sure the best way to describe what I want to do here, but I will attempt to.

I have a .zip file I want to extract, I have wrote the code to do this and it is working, but I want to "manipulate" the path when writing them to disk.
If I used IZArc to extract this .zip file, it is doing exactly what I want, but I am not sure why or how to make my code do this.

The zip file has a couple upper level folders that I do not care about, or want. The first "file" is located under dir2, so I would like that to be the "top" level folder.

Example (when viewing the zip file using IZARC)

dir/dir1/dir2/dir3/filename
dir/dir1/dir2/dir3/filename2

I understand that there are "folders" under dir and dir1 but all the files are located in dir2 and deeper.

If I extract using my code, the above is what I see in explorer for the directory structure. But if I use IZArc, it is not "keeping" dir or dir1, so the files are unzipped with the top level folder being dir2.

This is what gets saved to disk with my code:

dir/dir1/dir2/dir3/filename
dir/dir1/dir2/dir3/filename2
etc...

This is what gets saved if I use IZArc
dir2/dir3/filename
dir2/dir3/filename2
etc..

It is removing, or not keeping the first two folders...
My guess is because there is not a "file" in them... But just a guess.

I know I can probably manipulate the path or even save them and then move them to where I want, but was wondering if there was a way to have the java do this for me? Maybe a option when creating the ZipFile object or something?

I have looked through the settings of IZArc, to see if I can figure out why or how this program is eliminating those two top folders, but am unable to find anything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top