|
TrueZIP Driver ZIP 7.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.OutputStream
de.schlichtherle.truezip.io.DecoratingOutputStream
de.schlichtherle.truezip.zip.RawZipOutputStream<ZipEntry>
de.schlichtherle.truezip.zip.ZipOutputStream
public class ZipOutputStream
Drop-in replacement for
java.util.zip.ZipOutputStream.
This class starts writing ordinary ZIP32 File Format. It automatically adds ZIP64 extensions if required, i.e. if the file size exceeds 4GB or more than 65535 entries are written. This implies that the class may produce ZIP archive files which cannot be read by older ZIP implementations.
If the system property de.schlichtherle.truezip.io.zip.zip64ext
is set to true (case is ignored),
then ZIP64 extensions are always added when writing a ZIP archive file,
regardless of its size.
This system property is primarily intended for unit testing purposes.
During normal operations, it should not be set as many
third party tools would not treat the redundant ZIP64 extensions
correctly.
Note that it's impossible to inhibit ZIP64 extensions.
This class is thread-safe.
ZipFile| Field Summary |
|---|
| Fields inherited from class de.schlichtherle.truezip.zip.RawZipOutputStream |
|---|
DEFAULT_CHARSET |
| Fields inherited from class de.schlichtherle.truezip.io.DecoratingOutputStream |
|---|
delegate |
| Constructor Summary | |
|---|---|
ZipOutputStream(OutputStream out)
Constructs a ZIP output stream which decorates the given output stream using the "UTF-8" charset. |
|
ZipOutputStream(OutputStream out,
Charset charset)
Constructs a ZIP output stream which decorates the given output stream using the given charset. |
|
ZipOutputStream(OutputStream out,
ZipFile appendee)
Constructs a ZIP output stream which decorates the given output stream and apppends to the given raw ZIP file. |
|
| Method Summary | |
|---|---|
void |
close()
Closes this output stream and releases any system resources associated with the stream. |
void |
closeEntry()
Writes all necessary data for this entry to the underlying stream. |
Enumeration<? extends ZipEntry> |
entries()
Deprecated. Use iterator() instead. |
void |
finish()
Closes the current entry and writes the Central Directory to the underlying output stream. |
String |
getComment()
Returns the file comment. |
ZipEntry |
getEntry(String name)
Returns a clone of the entry for the given name or null if no
entry with this name exists. |
int |
getLevel()
Returns the compression level currently used. |
int |
getMethod()
Returns the default compression method for subsequent entries. |
boolean |
isBusy()
Returns true if and only if this
RawZipOutputStream is currently writing a ZIP entry. |
Iterator<ZipEntry> |
iterator()
Returns a safe iteration of clones for all entries written to this ZIP file so far. |
long |
length()
Returns the total number of (compressed) bytes this stream has written to the underlying stream. |
void |
putNextEntry(ZipEntry entry,
boolean deflate)
Starts writing the next ZIP entry to the underlying stream. |
void |
setComment(String comment)
Sets the file comment. |
void |
setLevel(int level)
Sets the compression level for subsequent entries. |
void |
setMethod(int method)
Sets the default compression method for subsequent entries. |
int |
size()
Returns the number of ZIP entries written so far. |
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
| Methods inherited from class de.schlichtherle.truezip.zip.RawZipOutputStream |
|---|
getCharset, putNextEntry |
| Methods inherited from class de.schlichtherle.truezip.io.DecoratingOutputStream |
|---|
flush, toString, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public ZipOutputStream(OutputStream out)
"UTF-8" charset.
NullPointerException - If out is null.
public ZipOutputStream(OutputStream out,
Charset charset)
NullPointerException - If any parameter is null.
public ZipOutputStream(OutputStream out,
ZipFile appendee)
throws ZipException
In order to append entries to an existing ZIP file, out must be
set up so that it appends to the same ZIP file from which
appendee is reading.
appendee may already be closed.
NullPointerException - If any parameter is null.
ZipException - if appendee has a postamble, i.e. some data
after its central directory and before its end.| Method Detail |
|---|
public int size()
RawZipOutputStream
size in class RawZipOutputStream<ZipEntry>public Enumeration<? extends ZipEntry> entries()
iterator() instead.
entries in class RawZipOutputStream<ZipEntry>public Iterator<ZipEntry> iterator()
iterator in interface Iterable<ZipEntry>iterator in class RawZipOutputStream<ZipEntry>public ZipEntry getEntry(String name)
null if no
entry with this name exists.
getEntry in class RawZipOutputStream<ZipEntry>name - the name of the ZIP entry.public void setComment(String comment)
RawZipOutputStream
setComment in class RawZipOutputStream<ZipEntry>public String getComment()
RawZipOutputStream
getComment in class RawZipOutputStream<ZipEntry>public void setLevel(int level)
RawZipOutputStream
setLevel in class RawZipOutputStream<ZipEntry>public int getLevel()
RawZipOutputStream
getLevel in class RawZipOutputStream<ZipEntry>public int getMethod()
RawZipOutputStreamZipEntry does not specify a
compression method.
getMethod in class RawZipOutputStream<ZipEntry>RawZipOutputStream.setMethod(int),
ZipEntry.getMethod()public void setMethod(int method)
RawZipOutputStreamZipEntry does not specify a
compression method.
Legal values are ZipEntry.STORED (uncompressed) and
ZipEntry.DEFLATED (compressed).
The initial value is ZipEntry.DEFLATED.
setMethod in class RawZipOutputStream<ZipEntry>RawZipOutputStream.getMethod(),
ZipEntry.setMethod(int)public long length()
RawZipOutputStream
length in class RawZipOutputStream<ZipEntry>public final boolean isBusy()
RawZipOutputStreamtrue if and only if this
RawZipOutputStream is currently writing a ZIP entry.
isBusy in class RawZipOutputStream<ZipEntry>
public void putNextEntry(ZipEntry entry,
boolean deflate)
throws IOException
RawZipOutputStreamjava.util.zip.ZipOutputStream which would throw a ZipException
in this method when the second entry with the same name is to be written.
putNextEntry in class RawZipOutputStream<ZipEntry>entry - The ZIP entry to write.deflate - Whether or not the entry data should be deflated.
This should be set to false if and only if you are
writing data which has been read from a ZIP file and has not
been inflated again.
The entries' properties CRC, compressed size and uncompressed
size must be set appropriately.
ZipException - If and only if writing the entry is impossible
because the resulting file would not comply to the ZIP file
format specification.
IOException - On any I/O related issue.
public void write(int b)
throws IOException
write in class RawZipOutputStream<ZipEntry>IOException - On any I/O related issue.
public void write(byte[] b,
int off,
int len)
throws IOException
write in class RawZipOutputStream<ZipEntry>IOException - On any I/O related issue.
public void closeEntry()
throws IOException
RawZipOutputStream
closeEntry in class RawZipOutputStream<ZipEntry>ZipException - If and only if writing the entry is impossible
because the resulting file would not comply to the ZIP file
format specification.
IOException - On any I/O related issue.
public void finish()
throws IOException
RawZipOutputStreamNotes:
finish in class RawZipOutputStream<ZipEntry>ZipException - If and only if writing the entry is impossible
because the resulting file would not comply to the ZIP file
format specification.
IOException - On any I/O related issue.
public void close()
throws IOException
RawZipOutputStream
close in interface Closeableclose in class RawZipOutputStream<ZipEntry>IOException - On any I/O related issue.
|
TrueZIP Driver ZIP 7.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||