Search code examples
javazipzipinputstream

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?


Solution

  • 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.