Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Problem in creating a zip file java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the following code to create the zip file in java


In c:/reports/reports/reports/reports/reports there are several files which I want to zip in zipFile.zip in the same directory.
The above code does the same....

But when I extract the zip file I get the directory structure like this ..../reports/reports/reports/reports/reports
and the files in the last folder..

I want only the files when I exctract the zip file.......

Suggest something.........
Thanks in advance................
 
Sheriff
Posts: 21841
105
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Don't add your files using absolute paths. Use relative paths instead.
 
sAsho wagh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But how would I get the relative path of the file..........

The executable file laction may be chaned in that case what should I do..........
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The name that appears in the zip file, including the path, is specified by what you pass to the ZipEntry constructor, so you need to change that.
 
sAsho wagh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thanks Joanne Neal..........

It Works now.............
 
What's that smell? I think this tiny ad may have stepped in something.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!