Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in creating a zip file java

 
sAsho wagh
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................
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java 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..........
 
Joanne Neal
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.............
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic