wood burning stoves 2.0*
The moose likes Java in General and the fly likes Problem in creating a zip file java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem in creating a zip file java" Watch "Problem in creating a zip file java" New topic
Author

Problem in creating a zip file java

sAsho wagh
Greenhorn

Joined: Jan 18, 2011
Posts: 3
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

Joined: Oct 27, 2005
Posts: 19655
    
  18

Welcome to the Ranch!

Don't add your files using absolute paths. Use relative paths instead.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
sAsho wagh
Greenhorn

Joined: Jan 18, 2011
Posts: 3
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

Joined: Aug 05, 2005
Posts: 3431
    
  12
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.


Joanne
sAsho wagh
Greenhorn

Joined: Jan 18, 2011
Posts: 3
Hey Thanks Joanne Neal..........

It Works now.............
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem in creating a zip file java
 
Similar Threads
How to unzip a file??
how to zip multiple files and directory into one output
compressing/uncompressing folders
Unable to create ,zip file
Zipping files