Hello, I used java.util.zip to create zip files. What I noticed is that if I try to open the zip file by double click on it, there's nothing inside. Also if I try to extract it manually (right click and choose extract), it will encounter error.
Has anyone encounter this before? This is so weird because the code I used is the common ones you can find on the internet.
Looks more or less okay to me. Of course if you pass it the name of a file that doesn't exist, it will throw an exception and you will have an empty zip file exactly as you describe. So better error-handling would be a good idea. Such as closing the ZipOutputStream in a finally block. At least then you would have an empty zip file that doesn't have errors.
Yeah guys, I finally solved it. The code won't work properly because the file name I passed into new ZipEntry() is a whole file path instead of name only. This actually caused it to reference the file path instead of creating it inside the zip file. Which is why my zip file still have a size but has no contents inside.
Anyway thanks a bunch for your help guys!
I'm not available, my BF's name is WORK.
There were millions of the little blood suckers. But thanks to this tiny ad, I wasn't bitten once.
a bit of art, as a gift, that will fit in a stocking