Share on Google+Share on Google+

Java ZipOutputStream

The package provides the class ZipOutputStream for writing ZIP files.

Java ZipOutputStream



The 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 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:




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


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


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:


Example: Java Zip

Read at :




Posted on: June 16, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Java ZipOutputStream  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image