ZipOutputStream 

Introduction

The java.util.zip.ZipOutputStream class implements an output stream filter for writing files in the ZIP file format. Includes support for both compressed and uncompressed entries.

Class Declaration

Following is the declaration for java.util.zip.ZipOutputStream class −

publicclassZipOutputStreamextendsDeflaterOutputStream

Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.

Fields

Following are the fields for java.util.zip.ZipOutputStream class −

  • static int CENATT
  • static int CENATX
  • static int CENCOM
  • static int CENCRC
  • static int CENDSK
  • static int CENEXT
  • static int CENFLG
  • static int CENHDR
  • static int CENHOW
  • static int CENLEN
  • static int CENNAM
  • static int CENOFF
  • static long CENSIG
  • static int CENSIZ
  • static int CENTIM
  • static int CENVEM
  • static int CENVER
  • static int DEFLATED − Compression method for compressed (DEFLATED) entries.
  • static int ENDCOM
  • static int ENDHDR
  • static int ENDOFF
  • static long ENDSIG
  • static int ENDSIZ
  • static int ENDSUB
  • static int ENDTOT
  • static int EXTCRC
  • static int EXTHDR
  • static int EXTLEN
  • static long EXTSIG
  • static int EXTSIZ
  • static int LOCCRC
  • static int LOCEXT
  • static int LOCFLG
  • static int LOCHDR
  • static int LOCHOW
  • static int LOCLEN
  • static int LOCNAM
  • static long LOCSIG
  • static int LOCSIZ
  • static int LOCTIM
  • static int LOCVER
  • static int STORED − Compression method for uncompressed (STORED) entries.

Constructors

Sr.No.Constructor & Description
1ZipOutputStream(OutputStream out)Creates a new ZIP output stream.
2ZipOutputStream(OutputStream out, Charset charset)Creates a new ZIP output stream.

Class Methods

Sr.No.Method & Description
1void close()Closes the ZIP output stream as well as the stream being filtered.
2void closeEntry()Closes the current ZIP entry and positions the stream for writing the next entry.
3void finish()Finishes writing the contents of the ZIP output stream without closing the underlying stream.
4void putNextEntry(ZipEntry e)Begins writing a new ZIP file entry and positions the stream to the start of the entry data.
5void setComment(String comment)Sets the ZIP file comment.
6void setLevel(int level)Sets the compression level for subsequent entries which are DEFLATED.
7void setMethod(int method)Sets the default compression method for subsequent entries.
8void write(byte[] b, int off, int len)Writes an array of bytes to the current ZIP entry data.

Methods Inherited

This class inherits methods from the following classes −

  • java.util.zip.DeflaterOutputStream
  • java.io.FilterOutputStream
  • java.lang.Object

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *