user1734143 user1734143 - 1 month ago 6
Java Question

java zipentry getsize returns -1

Java zipEntry.getSize() returns the size of the actual file and some times it returns -1 (though the file size is greater than 0).

Java API document says "Returns the uncompressed size of the entry data, or -1 if not known."

Not sure on what situation it will return -1 i.e. on what situation it will be unknown?

Answer

you'll get a return of -1 if that is what is in the ZipFile entry table. This is quite simply just an aspect of the definition of the zip file format.

Comments