File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 19653
    
  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
writing data to zip file
how to put two different folders(which is in different location) into one zip entry
Windows XP Compressed Folders doesn't recognize my Java-created zip file
how to zip multiple files and directory into one output
Problem When Compressing Directory