This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 19649
    
  18

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
 
Similar Threads
how to zip multiple files and directory into one output
writing data to zip file
Windows XP Compressed Folders doesn't recognize my Java-created zip file
Problem When Compressing Directory
how to put two different folders(which is in different location) into one zip entry