@NotThreadSafe public class ZipOutputStream extends AbstractZipOutputStream<ZipEntry>
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 net.truevfs.kernel.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.
ZipFile
Modifier and Type | Field and Description |
---|---|
static Charset |
DEFAULT_CHARSET
The default character set used for entry names and comments in ZIP files.
|
Constructor and Description |
---|
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 appends to the given ZIP file.
|
Modifier and Type | Method and Description |
---|---|
ZipEntry |
entry(String name)
Returns a clone of the entry for the given
name or null
if no entry with this name exists in this ZIP file. |
ZipCryptoParameters |
getCryptoParameters()
Returns the parameters for encryption or authentication of entries.
|
Iterator<ZipEntry> |
iterator()
Returns a safe iteration of clones for all entries written to this ZIP
file so far.
|
void |
setCryptoParameters(ZipCryptoParameters cryptoParameters)
Sets the parameters for encryption or authentication of entries.
|
close, closeEntry, finish, getCharset, getComment, getLevel, getMethod, getRawCharset, isBusy, length, putNextEntry, putNextEntry, setComment, setLevel, setMethod, size
flush, toString, write, write, write
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
public static final Charset DEFAULT_CHARSET
"UTF-8"
for compatibility with Sun's JDK implementation.@CreatesObligation public ZipOutputStream(@WillCloseWhenClosed OutputStream out) throws IOException
"UTF-8"
charset.out
- The output stream to write the ZIP file to.IOException
- on any I/O error.@CreatesObligation public ZipOutputStream(@WillCloseWhenClosed OutputStream out, Charset charset) throws IOException
out
- The output stream to write the ZIP file to.charset
- the character set to use.IOException
- on any I/O error.@CreatesObligation public ZipOutputStream(@WillCloseWhenClosed OutputStream out, ZipFile appendee) throws IOException
out
- The output stream to write the ZIP file to.
If appendee
is not null
, then this must be set
up so that it appends to the same ZIP file from which
appendee
is reading.appendee
- the ZIP file to append to.
This may already be closed.IOException
- on any I/O error.public ZipEntry entry(String name)
name
or null
if no entry with this name exists in this ZIP file.entry
in class AbstractZipOutputStream<ZipEntry>
name
- the name of the ZIP entry.name
or null
if no entry with this name exists in this ZIP file.@Nullable public ZipCryptoParameters getCryptoParameters()
AbstractZipOutputStream
getCryptoParameters
in class AbstractZipOutputStream<ZipEntry>
public Iterator<ZipEntry> iterator()
public void setCryptoParameters(@CheckForNull ZipCryptoParameters cryptoParameters)
Note that only WinZip AES encryption
is
currently supported.
cryptoParameters
- the parameters for encryption or authentication
of entries.Copyright © 2005–2018 Schlichtherle IT Services. All rights reserved.