I searched and read all questions about ZipEntry (JAVA 7) but my problem is nowhere addressed:
I successfully zip and unzip files in JAVA, but although, at zip time, I set the uncompressed size by ZipEntry.setSize(long)
to values surely smaller than int value,
reading back, at unzip time, by ZipEntry.getSize()
always returns -1.
Although my programs run well, the verification part warns for unknown size
.
How do I set the uncompressed size?
At first sight it looks like a bug, but as explained here it's actually not!
The size information (along with some other info like CRC) is stored compressed so to get access to this information you have to:
getNextEntry()
to get the first entrygetSize()
will return -1read(buffer)
getNextEntry()
againgetSize()
on the first entry will now return the correct size!Weird, but that's how it apparently is supposed to work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With