What is DEFAULT_COMPRESSION?

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

+8
java gzip zlib deflate
source share
2 answers

Z_DEFAULT_COMPRESSION should be a good compromise between speed and compression efficiency. This is the knee on the curve. The actual level that it is currently equivalent to 6 is an internal choice that may change in future versions if the compression algorithm changes. Thus, you should not depend on this, remaining equivalent to level 6.

+7
source share

The java code uses the class new ZStreamRef(init(level, DEFAULT_STRATEGY, nowrap)); The init method is its own call, and ZStreamRef is a reference to zlib . Thus, its use of zlib is used as the default. In version 1.2.8, the default value is 6, as indicated by devnull.

From the zlib manual

 Compression levels. #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) ... Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6). 
+9
source share

All Articles