Compressing and Decompressing File
The DeflaterOutputStream and InflaterInputStream classes provide mechanism to compress and decompress the data in the deflate compression format.
The DeflaterOutputStream class is used to compress the data in the deflate compression format. It provides facility to the other compression filters, such as GZIPOutputStream.
Example of Compressing file using DeflaterOutputStream class
In this example, we are reading data of a file and compressing it into another file using DeflaterOutputStream class. You can compress any file, here we are compressing the Deflater.java file
The InflaterInputStream class is used to decompress the file in the deflate compression format. It provides facility to the other decompression filters, such as GZIPInputStream class.
Example of decompressing file using InflaterInputStream class
In this example, we are decompressing the compressed file def.txt into D.java .