
Java 6 provide the utility classes for the compression and decompression which we have seen in the last page. The file java.util.zip.ZipOutputStream is provided by Java 6 to compress the files in the zip format. Zip is common format for Windows environment and is widely accepted in IT world. The below example will show how we can use the ZipOutputStream to compress the files in the zip format.
Example:-
Note:- The below example will except the file names as command line argument. Please provide the full path names for the file.
package com.visualbuilder; import java.io.BufferedOutputStream; public class ZipCompressionExample { |
Output:-
When the above program runs it will generate the test.zip file in C Drive. It contains all the files which is passed in the command line as arguments in compressed format.
Java Discussion
- - Java web application
- - Difference between BMT an
- - Replace getParameterValue
- - Interviewing Next week -
- - Sudoku solver




