Java ZipOutputStream

The java.util.zip package provides the class ZipOutputStream for writing ZIP files.

Java ZipOutputStream

Java ZipOutputStream

     

 

The java.util.zip package provides the class ZipOutputStream for writing ZIP files. In order to compress data to a ZIP file, Java provides the ZipOutputStream class defined in the java.util.zip package. This class provides the functionality of writing the data in a compressed format. The constructor for this class accepts an OutputStream object. Basically, you can pass the output stream of the file you are writing to.


 
The following table shows the method summary of the ZipOutputStream class:

Method

Summary

close()

Closes the ZIP output stream as well as the stream being filtered.

closeEntry()  

Closes the current ZIP entry and positions the stream for writing the next entry.

finish()

Finishes writing the contents of the ZIP output stream without closing the underlying stream.

putNextEntry(ZipEntry e)

Begins writing a new ZIP file entry and positions the stream to the start of the entry data.

setComment(String comment)

Sets the ZIP file comment.

setLevel(int level)

Sets the compression level for subsequent entries, which are DEFLATED.

setMethod(int method)

Sets the default compression method for subsequent entries.

write(byte[] b, int off, int len)

Writes an array of bytes to the current ZIP entry data.

 


Read more at:

http:/www.roseindia.net/java/example/java/io/ZipCreateExample.shtml

Example: Java Zip

Read at :

http:/www.roseindia.net/java/example/java/io/