Home » Category » Enterprise Technologies

Enterprise Technologies: zipping files

300| Fri, 21 Sep 2007 07:53:00 GMT| chumchumma| Comments (4)

I'm trying to create a zip utility which takes in a certain directory's location and zips up all files and sub-directories. I have coded the recursive logic needed to also zip the subdirectories but I'm getting a FileNotFound exception with the sub-directories. here is an example: "java.io.FileNotFoundException: C:\out\images (Access is denied)" Please let me know if there is any security settings which I can override to prevent this error.

Keywords & Tags: zipping, files, enterprise

URL: http://java.itags.org/java-enterprise/73731/
 
«« Prev - Next »» 4 helpful answers below.
I have checked using forward slashes on windows -- winZip seems to handle it fine. I do not know about backslash directory markers on unzip for *n?x.

dracheflya | Sat, 14 Jul 2007 21:42:00 GMT |

Yes, but how do you specify that the recursively contained file should unpack into the same directory structure? They way you just outlined it it looks like they will all be flattened out. Perhaps if you were to elaborate on the 'do the file zipping stuff' section to demonstrate how the directory structure will be maintained...

dracheflya | Sat, 14 Jul 2007 21:42:00 GMT |

Er.. I mean, if you specify a path with one separator character, e.g. '\' or '/', would this be portable from one system to another?

dracheflya | Sat, 14 Jul 2007 21:42:00 GMT |

Looks like you are trying to open a directory.

You should only open files.

if (a_file.isDirectory()) {

zipDirectory(a_file.toString(), out);

}

else {

// do the file-zipping stuff

}

//

// method checks recursively for dirs

zipDirectory(File fi, ZipOutputStream out){

// loop through the dir entries : String[] entries = fi.list();

if(entry.isDirectory())

zipDirectory(..)// recursive call

else

// fo the file-zipping stuff

}

Try that if you're doing it already, and repost if problem subsists.

gypsy617a | Sat, 14 Jul 2007 21:42:00 GMT |

Enterprise Technologies Hot Answers

Enterprise Technologies New questions

Enterprise Technologies Related Categories