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:
I have created into C: a folder named teste50 that has into it a child folder named 1 the has two .doc files, so, the method can find but compress only the folder no compress her children the files... Look at below please:
If you really want people to help you, you need to get in the habit to TellTheDetails. What do you think an exception name is worth without either the exception message or the line of code in which it happens?
sorry that works but not 100% right... let me explain better:
if you try to compress a folder named exemple folder1 that has a child named file1 together another file named file2 that compresses but when you descompress the result is -> file1 and file2 instead of folder1/file1 and file2.
She's out of the country right now, toppling an unauthorized dictatorship. Please leave a message with this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss