I have written a zip code which can zip files from a directory into 1 zip file. However, when it encounters a folder in that directory, it compresses the folder into a seperate zip file.
Below is the code:
The part where the folder is dealt with is under the "elseif fileArray[i].isDirectory()) ". Recursion is used to get into the folder to read the files inside for compression.
I have made the file and zip output streams to have the same location (destZipFile) so that the folder to be compressed can be placed in the same zip file. However, when I ran the program, there is no trace of the folder being zipped.
How do I manage to zip all files and folders inside a directory into 1 zip file?
You're creating a new ZipOutputStream every time you call the method. These two linesneed to be taken out and put before the first call to your method. Then pass zipOS to the method instead of destZipFile. [ January 24, 2008: Message edited by: Joanne Neal ]
subject: How to zip files and folders in a directory into 1 zip file?