|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
de.schlichtherle.util.zip.BasicZipOutputStream
de.schlichtherle.util.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.util.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.util.zip.BasicZipOutputStream |
---|
DEFAULT_CHARSET |
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
ZipOutputStream(OutputStream out)
Creates a new ZIP output stream decorating the given output stream, using the UTF-8 charset. |
|
ZipOutputStream(OutputStream out,
String charset)
Creates a new ZIP output stream decorating the given output stream. |
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 |
entries()
Returns a safe enumeration of clones of the ZIP entries written so far. |
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 ZipEntry for the given name or
null if no entry with that 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
BasicZipOutputStream is currently writing a ZIP entry. |
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.util.zip.BasicZipOutputStream |
---|
getEncoding, putNextEntry |
Methods inherited from class java.io.FilterOutputStream |
---|
flush, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ZipOutputStream(OutputStream out) throws NullPointerException
NullPointerException
- If out
is null
.public ZipOutputStream(OutputStream out, String charset) throws NullPointerException, UnsupportedEncodingException
NullPointerException
- If out
or charset
is
null
.
UnsupportedEncodingException
- If charset is not supported by
this JVM.Method Detail |
---|
public int size()
BasicZipOutputStream
size
in class BasicZipOutputStream
public Enumeration entries()
entries
in class BasicZipOutputStream
public ZipEntry getEntry(String name)
ZipEntry
for the given name or
null
if no entry with that name exists.
getEntry
in class BasicZipOutputStream
name
- Name of the ZIP entry.public void setComment(String comment)
BasicZipOutputStream
setComment
in class BasicZipOutputStream
public String getComment()
BasicZipOutputStream
getComment
in class BasicZipOutputStream
public void setLevel(int level)
BasicZipOutputStream
setLevel
in class BasicZipOutputStream
public int getLevel()
BasicZipOutputStream
getLevel
in class BasicZipOutputStream
public int getMethod()
BasicZipOutputStream
ZipEntry
does not specify a
compression method.
getMethod
in class BasicZipOutputStream
BasicZipOutputStream.setMethod(int)
,
ZipEntry.getMethod()
public void setMethod(int method)
BasicZipOutputStream
ZipEntry
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 BasicZipOutputStream
BasicZipOutputStream.getMethod()
,
ZipEntry.setMethod(int)
public long length()
BasicZipOutputStream
length
in class BasicZipOutputStream
public final boolean isBusy()
BasicZipOutputStream
true
if and only if this
BasicZipOutputStream
is currently writing a ZIP entry.
isBusy
in class BasicZipOutputStream
public void putNextEntry(ZipEntry entry, boolean deflate) throws IOException
BasicZipOutputStream
java.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 BasicZipOutputStream
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 archive 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 BasicZipOutputStream
IOException
- On any I/O related issue.public void write(byte[] b, int off, int len) throws IOException
write
in class BasicZipOutputStream
IOException
- On any I/O related issue.public void closeEntry() throws IOException
BasicZipOutputStream
closeEntry
in class BasicZipOutputStream
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
BasicZipOutputStream
Notes:
finish
in class BasicZipOutputStream
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
BasicZipOutputStream
close
in interface Closeable
close
in class BasicZipOutputStream
IOException
- On any I/O related issue.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |