java.util.zip
Class ZipOutputStream
java.lang.Object
|
+--java.io.OutputStream
|
+--java.io.FilterOutputStream
|
+--java.util.zip.DeflaterOutputStream
|
+--java.util.zip.ZipOutputStream
All Implemented Interfaces:
java.util.zip.ZipConstants
This is a FilterOutputStream that writes the files into a zip
archive one after another. It has a special method to start a new
zip entry. The zip entries contains information about the file name
size, compressed size, CRC, etc.
It includes support for STORED and DEFLATED entries.
This class is not thread safe.
Author:DEFLATED
public static final int DEFLATED
Compression method. This method uses the Deflater.
STORED
public static final int STORED
Compression method. This method doesn't compress at all.
ZipOutputStream
public ZipOutputStream(java.io.OutputStream out)
Creates a new Zip output stream, writing a zip archive.
Parameters:
closeEntry
public void closeEntry()
Closes the current entry.
Throws:
finish
public void finish()
Finishes the stream. This will write the central directory at the
end of the zip file and flush the stream.
Throws:
putNextEntry
public void putNextEntry(java.util.zip.ZipEntry entry)
Starts a new Zip entry. It automatically closes the previous
entry if present. If the compression method is stored, the entry
must have a valid size and crc, otherwise all elements (except
name) are optional, but must be correct if present. If the time
is not set in the entry, the current time is used.
Parameters:
Throws:
setComment
public void setComment(java.lang.String comment)
Set the zip file comment.
Parameters:
Throws:
setLevel
public void setLevel(int level)
Sets default compression level. The new level will be activated
immediately.
Parameters:
Throws:
See Also:
setMethod
public void setMethod(int method)
Sets default compression method. If the Zip entry specifies
another method its method takes precedence.
Parameters:
Throws:
See Also:
write
public void write(byte[] b, int off, int len)
Writes the given buffer to the current entry.
Parameters:
Throws: