public class ZipOutput extends Object
| Constructor and Description |
|---|
ZipOutput(OutputStream outputStream)
Creates a new ZipOutput.
|
ZipOutput(OutputStream outputStream,
byte[] header,
String comment,
int uncompressedAlignment)
Creates a new ZipOutput that aligns uncompressed entries.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the zip archive, also closing the underlying output stream.
|
OutputStream |
createOutputStream(String name,
boolean compress,
int modificationTime)
Creates a new zip entry, returning an output stream to write its data.
|
OutputStream |
createOutputStream(String name,
boolean compress,
int modificationTime,
byte[] extraField,
String comment)
Creates a new zip entry, returning an output stream to write its data.
|
static void |
main(String[] args)
Provides a simple test for this class, creating a zip file with the
given name and a few aligned/compressed/uncompressed zip entries.
|
public ZipOutput(OutputStream outputStream) throws IOException
outputStream - the output stream to which the zip data will be
written.IOExceptionpublic ZipOutput(OutputStream outputStream, byte[] header, String comment, int uncompressedAlignment) throws IOException
outputStream - the output stream to which the zip data will
be written.header - an optional header for the jar file.comment - optional comment for the entire zip file.uncompressedAlignment - the requested alignment of uncompressed data.IOExceptionpublic OutputStream createOutputStream(String name, boolean compress, int modificationTime) throws IOException
name - the name of the zip entry.compress - specifies whether the entry should be compressed.modificationTime - the modification date and time of the zip entry,
in DOS format.IOExceptionpublic OutputStream createOutputStream(String name, boolean compress, int modificationTime, byte[] extraField, String comment) throws IOException
name - the name of the zip entry.compress - specifies whether the entry should be compressed.modificationTime - the modification date and time of the zip entry,
in DOS format.extraField - optional extra field data. These should contain
chunks, each with a short ID, a short length
(little endian), and their corresponding data.
The IDs 0-31 are reserved for Pkware.
Java's jar tool just specifies an ID 0xcafe on
its first entry.comment - optional comment.IOExceptionpublic void close()
throws IOException
IOExceptionpublic static void main(String[] args)
Copyright © 2019. All rights reserved.