Zip File: Zip file format is the popular method of data compression. Zip file contains many files in compressed format. You can say the files are stored in the zip format with compression. The file which is in the zip format holds the ".zip" extension.
You can make executable file in zip format. You can archive data from the zip file by extracting it. For create a zip file from other type of file, following program gives you the best way of making it possible through you code in java application.
This program makes a zip file from only one file which is given by you. It takes a file to make it into zip format and it takes the zip file name which has to be created from the given file. Finally, it makes the zip file. You can archive the file from the zip file by extracting, if you want.
Several methods and APIs are used in the following program for making a zip file from the given file. These are explained as follows:
ZipOutputStream is the class of java.util.zip.*; package. This class is used to compression the file whether the file is compressed on uncompressed.
Above mentioned is the setLevel() method of ZipOutputStream class which sets the level of the compression process. This method takes a argument which is the built-in field of the Deflater class.
This is the class of java.util.zip.*; package. This class provides the compression using the ZLIB compression library.
Here is the code of the program:
Recommend the tutorial