A deep dive into accurately calculating the true size impact of individual entries in a zip file using Java. Simply summing `ZipEntry.getCompressedSize()` values doesn't match the actual zip file size because local file headers (30 bytes + name + extra), central directory records (46 bytes + name + extra + comment), and the end-of-directory record (22 bytes + comment) all contribute to the total. Two utility methods are provided — `entryImpactBytes` and `additionalBytes` — that together produce a sum exactly matching the zip file size. This is especially useful when comparing two versions of a zip to compute accurate byte-level diffs, such as when both file content and filename length change.
3 Impressions