Search code examples
javagzipzlibdeflate

What exactly is DEFAULT_COMPRESSION?


Of the possible DEFLATE compression levels [0 .. 9], which one exactly Java's Deflater.DEFAULT_COMPRESSION correspond to? In the Java source code, I see it as public static final int DEFAULT_COMPRESSION = -1;


Solution

  • Z_DEFAULT_COMPRESSION is intended to be a good compromise between speed and compression effectiveness. It is the knee in the curve. The actual level that it's currently equivalent to, 6, is an internal choice that could change in future versions if the compression algorithm changes. So you should not depend on it remaining equivalent to level 6.