anjana
anjana

Reputation: 35

Unzipping without first directory in java

I would like a zip file Test.zip containing 2 folders, say, A and B, to be unzipped outside of Test folder. For now A and B are unzipped within Test folder i.e Test->A and Test->B, whereas I want it in a different folder like Test2->A and Test2->B. right now I am getting an output like Test2->Test->A. How can i achieve this? Please help.

Upvotes: 0

Views: 914

Answers (1)

G_H
G_H

Reputation: 11999

It sounds to me like your Test.zip file simply contains a folder named "Test" that in turn contains A and B. Could you verify if this is the case?

If that's so, maybe you could detect if the zip file contains a single directory with the same name as the file. If that is so, extract from that subdirectory into your target. If not, extract directly from the zip root.

Upvotes: 2

Related Questions