java.util.zip - ZipOutputStream Class


Advertisements


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 −

public class ZipOutputStream
   extends DeflaterOutputStream

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

S.N. Constructor & Description
1 ZipOutputStream(OutputStream out)

Creates a new ZIP output stream.

2 ZipOutputStream(OutputStream out, Charset charset)

Creates a new ZIP output stream.

Class methods

S.N. Method & Description
1 void close()

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

2 void closeEntry()

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

3 void finish()

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

4 void putNextEntry(ZipEntry e)

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

5 void setComment(String comment)

Sets the ZIP file comment.

6 void setLevel(int level)

Sets the compression level for subsequent entries which are DEFLATED.

7 void setMethod(int method)

Sets the default compression method for subsequent entries.

8 void 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


Advertisements