posted 15 years ago
Obviously, File.listFiles() is your best friend in this example. Without it, recursion is going to be hard.
That said, the biggest issue is building the folder structure inside your ZIP file. You can't use only getName() when creating ZipEntry objects, since then you loose the path information. Using the absolute path is also not a good idea, since it will add too much path information. toString() looks like a good idea but has the same problem as the absolute path if the file is absolute.
I've solved this in the past by specifying the parent path myself: