Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot maitain dir structure when zipping files

 
sadanand munswamy
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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), "").
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic