This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Java in General and the fly likes Cannot maitain dir structure when zipping files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Cannot maitain dir structure when zipping files" Watch "Cannot maitain dir structure when zipping files" New topic
Author

Cannot maitain dir structure when zipping files

sadanand munswamy
Ranch Hand

Joined: Apr 10, 2012
Posts: 39
Dear Ranchers, I need help with java zip utility, My below code snippet is not able to maintain the Dir
structure, i.e it zips all the files into a single out Dir, also it starts zipping the all the Dir on the absolute path
of the input e.g if input is C:\\dir1\dir2\dir3 i want it to zip only files in dir3 and its sub directories. HELP !!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19914
    
  23

I've answered this question quite a while ago: http://www.coderanch.com/t/455191/java/java/When-Compressing-Directory. If you check my last post, the magic is in lines 50 and 51. You would call the second method as addToZip(zos, new File(dirpath), "").


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Cannot maitain dir structure when zipping files