This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to put two different folders(which is in different location) into one zip entry Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to put two different folders(which is in different location) into one zip entry " Watch "how to put two different folders(which is in different location) into one zip entry " New topic
Author

how to put two different folders(which is in different location) into one zip entry

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Hi Folks,

I have log files in different location in my system say C:\\javaLog and D:\\cLog i need to compress these folders and put into a single zip file .

How can i do this?. i tried with java.util.zip...but i cant make it exactly what i want.Please give me an idea .
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Don't think this is a beginner's topic. Moving.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19726
    
  20

The issue will be the names for the ZIP entries, and recursion comes to the rescue:

This method will take the original name (e.g. javaLog), and all of its files will keep that name part (e.g. javaLog/image.jpg, javaLog/folder/document.txt, etc).

I omitted the actual zipping part, but I don't think that will be a problem.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

the two log folders are in different location.


Here i am getting the zip file .if i extract i am getting inFolder\\java . thats is second path is overridding the first one. i want both folder in one zip .


Note: under the inFolder there are many logfolder. i need only two of them(in some situation). so i reject to zip the parent folder(inFolder)
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks Rob. problem solved.

i need to put outside the for loop
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to put two different folders(which is in different location) into one zip entry