File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes can you help me? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "can you help me?" Watch "can you help me?" New topic
Author

can you help me?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 543

i have written a method which zip a folder which only contains multiple files but when there is sub folder within that folder my code breaks, so i have written this method
which list the entire files in a directory by recursive call but still this code fails to achieve what i want
output of this code is just a folder with the name like if i specify to zip a "abc " folder and the destination name would be "abc.zip" i get a "folder" named "abc.zip"

can any one help me ?



The Only way to learn is ...........do!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 3133
In the future, please UseAMeaningfulSubjectLine(⇐click) so people will know at a glance what your question is about and can then easily decide whether they're interested in pursuing it.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 3133
It would be easier to understand what you're trying to do if you gave your method a meaningful name. I think what you're trying to do (but I'm not sure) is zip up an entire directory structure--including files and subdirectories--into a single zip file. Is that right?

If this is what you're trying to do, then why are you creating a new output file for each input file you encounter?

If this is not what you're trying to do, please explain it more clearly.
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 1900

If I understand correctly, you want a File named "abc.zip." But what is really happening is that a Folder named "abc.zip" is being created, not a File.

The reason for this is line 10:

This method specifically makes the a Folder (or directory) with the name you provide it. Instead, if you want to make sure all the folders in which the abc.zip file is supposed to be stored are made, then you should do:


Steve
 
 
subject: can you help me?
 
Threads others viewed
Problem zipping the file
Not able to put some files inside Zip file
I cant figure out why this zipping code produces an exception :(
Unable to create ,zip file
How to zip files and folders in a directory into 1 zip file?
developer file tools