• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot maitain dir structure when zipping files

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've answered this question quite a while ago: https://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), "").
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic