This class implements the general ZLIB data-compression algorithm used by the gzip and PKZip compression programs. The constants defined by this class are used to specify the compression strategy and the compression speed/strength tradeoff level to be used. If you set the nowrap argument to the constructor to true, the ZLIB header and checksum data are omitted from the compressed output, which is the format both gzip and PKZip use.

The important methods of this class are setInput( ), which specifies input data to be compressed, and deflate( ), which compresses the data and returns the compressed output. The remaining methods exist so that Deflater can be used for stream-based compression, as it is in higher-level classes, such as GZIPOutputStream and ZipOutputStream. These stream classes are sufficient in most cases. Most applications do not need to use Deflater directly. The Inflater class uncompresses data compressed with a Deflater object.

public class Deflater {
// Public Constructors
     public Deflater( );  
     public Deflater(int level);  
     public Deflater(int level, boolean nowrap);  
// Public Constants
     public static final int BEST_COMPRESSION;                           =9
     public static final int BEST_SPEED;                                 =1
     public static final int DEFAULT_COMPRESSION;                        =-1
     public static final int DEFAULT_STRATEGY;                           =0
     public static final int DEFLATED;                                   =8
     public static final int FILTERED;                                   =1
     public static final int HUFFMAN_ONLY;                               =2
     public static final int NO_COMPRESSION;                             =0
                  // Public Instance Methods ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.