Gzipped files typically end in .gz
. But, is there an official (or common) file extension or suffix for deflated files? I could not find any.

- 57,710
- 92
- 283
- 453
-
As that is just one method that e.g. ZIP is using (if I'm not mistaken), I'd use `.zip` for the extension. – Mar 21 '12 at 14:07
-
1No, don't use .zip unless the file is in ZIP format, which is not what the poster is talking about. – Mark Adler Mar 21 '12 at 14:33
1 Answers
There is an extension defined for zlib-wrapped (RFC-1950) deflate-compressed (RFC-1951) files, which is ".zz". There is no extension defined for raw deflate-compressed data (RFC-1951) that I know of. In general raw deflate data is only used within the context of some other data stream or file format.
The Java documentation is not clear about what is produced, but it looks like the default Deflater produces zlib-wrapped deflate data, unless the nowrap boolean is true in which case raw deflate-compressed data is produced.
More background
It's interesting to see that folk tend to think that all of these formats can be interpreted by anything that reads one of them, simply because the core compressed format (deflate) is the same. That is not the case. The gzip utility can read gzip-wrapped deflate data or single-entry zip files (and some legacy formats unrelated to deflate), but not zlib or raw deflate.
Info-ZIP's unzip can only read the ZIP format, which can include deflate data as one of the compressed data formats (there are others). zlib is a library, not a utility, and provides direct support for reading and writing the zlib format (a very compact wrapper around deflate data), the gzip format, and the raw deflate format with no wrapper. The latter can be used by other utilities to process deflate data in other formats, such as ZIP.
You can write your own zipper and unzipper using zlib to handle the heavy lifting for compression and decompression (as well as crc calculation), but you would have to handle all of the complexities of the ZIP format headers, trailers, and central dictionaries. pigz can read gzip, single-entry zip files, and the zlib format (as well as the old compress format).

- 16,038
- 10
- 74
- 104

- 101,978
- 13
- 118
- 158
-
This statement is not true: _The gzip utility can only read gzip-wrapped deflate data_. From gzip man: `gunzip can currently decompress files created by gzip, zip, compress, compress -H or pack.` – Oleg Mikheev Mar 22 '12 at 11:49
-
Yes, that's correct. gunzip will decompress a *single entry* zip file. It also contains some legacy decompressors for obsolete formats (compress and pack). – Mark Adler Mar 22 '12 at 15:47
-
-