| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
FileOutputStream fos = …;
ZipOutputStream zos = new ZipOutputStream(fos);
Based on 45 examples
public class ZipOutputStream extends DeflaterOutputStream implements ZipConstants
This class implements an output stream filter for writing files in the ZIP file format. Includes support for both compressed and uncompressed entries.
Field Summary | |
---|---|
static int |
DEFLATED
Compression method for compressed (DEFLATED) entries. |
static int |
STORED
Compression method for uncompressed (STORED) entries. |
Fields inherited from class java.util.zip.DeflaterOutputStream |
---|
buf, def |
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
Creates a new ZIP output stream. |
Method Summary | |
---|---|
void |
close() Closes the ZIP output stream as well as the stream being filtered. |
void |
Closes the current ZIP entry and positions the stream for writing the next entry. |
void |
finish() Finishes writing the contents of the ZIP output stream without closing the underlying stream. |
void |
Begins writing a new ZIP file entry and positions the stream to the start of the entry data. |
void |
setComment(String comment) Sets the ZIP file comment. |
void |
setLevel(int level) Sets the compression level for subsequent entries which are DEFLATED. |
void |
setMethod(int method) Sets the default compression method for subsequent entries. |
void |
write(byte[] b, int off, int len) Writes an array of bytes to the current ZIP entry data. |
Methods inherited from class java.util.zip.DeflaterOutputStream |
---|
close, deflate, finish, write, write |
Methods inherited from class java.io.FilterOutputStream |
---|
close, flush, write, write, write |
Methods inherited from class java.io.OutputStream |
---|
close, flush, write, write, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFLATED
public static final int STORED
Constructor Detail |
---|
public ZipOutputStream(OutputStream out)
out
- the actual output streamMethod Detail |
---|
public void close() throws IOException
close
in class DeflaterOutputStream
IOException
- if an I/O error has occurredpublic void closeEntry() throws IOException
IOException
- if an I/O error has occurredpublic void finish() throws IOException
finish
in class DeflaterOutputStream
IOException
- if an I/O exception has occurredpublic void putNextEntry(ZipEntry e) throws IOException
e
- the ZIP entry to be writtenIOException
- if an I/O error has occurredpublic void setComment(String comment)
comment
- the comment stringpublic void setLevel(int level)
level
- the compression level (0-9)public void setMethod(int method)
method
- the default compression methodpublic synchronized void write(byte[] b, int off, int len) throws IOException
write
in class DeflaterOutputStream
b
- the data to be writtenoff
- the start offset in the datalen
- the number of bytes that are writtenIOException
- if an I/O error has occurred
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |