public class ZipOutput
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected java.io.DataOutputStream |
outputStream |
| Constructor and Description |
|---|
ZipOutput(java.io.DataOutputStream outputStream,
byte[] header,
int uncompressedAlignment,
java.lang.String comment)
Creates a new ZipOutput that aligns uncompressed entries and contains a comment.
|
ZipOutput(java.io.DataOutputStream outputStream,
int uncompressedAlignment,
java.lang.String comment)
Creates a new ZipOutput that aligns uncompressed entries and contains a comment.
|
ZipOutput(java.io.OutputStream outputStream)
Creates a new ZipOutput.
|
ZipOutput(java.io.OutputStream outputStream,
byte[] header,
int uncompressedAlignment)
Creates a new ZipOutput that aligns uncompressed entries.
|
ZipOutput(java.io.OutputStream outputStream,
byte[] header,
int uncompressedAlignment,
java.lang.String comment)
Creates a new ZipOutput that aligns uncompressed entries and contains a comment.
|
ZipOutput(java.io.OutputStream outputStream,
int uncompressedAlignment)
Creates a new ZipOutput that aligns uncompressed entries.
|
ZipOutput(java.io.OutputStream outputStream,
int uncompressedAlignment,
java.lang.String comment)
Creates a new ZipOutput that aligns uncompressed entries and contains a comment.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the zip archive, writing out its central directory and closing
the underlying output stream.
|
void |
close(long centralDirectoryOffset)
Closes the zip archive, writing out its central directory and closing
the underlying output stream.
|
java.io.OutputStream |
createOutputStream(java.lang.String name,
boolean compress,
int modificationTime)
Creates a new zip entry, returning an output stream to write its data.
|
java.io.OutputStream |
createOutputStream(java.lang.String name,
boolean compress,
int uncompressedAlignment,
int modificationTime)
Creates a new zip entry, returning an output stream to write its data.
|
java.io.OutputStream |
createOutputStream(java.lang.String name,
boolean compress,
int uncompressedAlignment,
int modificationTime,
byte[] extraField,
java.lang.String comment)
Creates a new zip entry, returning an output stream to write its data.
|
static void |
main(java.lang.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.
|
protected long |
size()
Returns the current size of the data written to the output stream.
|
protected void |
writeEndOfCentralDirectory(long centralDirectoryOffset,
long centralDirectorySize)
Ends the central directory.
|
protected long |
writeEntriesOfCentralDirectory()
Writes the zip entries in the central directory.
|
protected void |
writeInt(int value)
Writes out a little-endian int value to the zip output stream.
|
protected void |
writeInt(long value)
Writes out a little-endian int value to the zip output stream.
|
protected void |
writeLong(long value)
Writes out a little-endian long value to the zip output stream.
|
protected void |
writeShort(int value)
Writes out a little-endian short value to the zip output stream.
|
protected long |
writeStartOfCentralDirectory()
Starts the central directory.
|
public ZipOutput(java.io.OutputStream outputStream)
outputStream - the output stream to which the zip data will be
written.public ZipOutput(java.io.OutputStream outputStream,
int uncompressedAlignment)
outputStream - the output stream to which the zip data will
be written.uncompressedAlignment - the default alignment of uncompressed data.public ZipOutput(java.io.OutputStream outputStream,
int uncompressedAlignment,
java.lang.String comment)
outputStream - the output stream to which the zip data will
be written.uncompressedAlignment - the default alignment of uncompressed data.comment - optional comment for the entire zip file.public ZipOutput(java.io.DataOutputStream outputStream,
int uncompressedAlignment,
java.lang.String comment)
outputStream - the output stream to which the zip data will
be written.uncompressedAlignment - the default alignment of uncompressed data.comment - optional comment for the entire zip file.public ZipOutput(java.io.OutputStream outputStream,
byte[] header,
int uncompressedAlignment)
throws java.io.IOException
outputStream - the output stream to which the zip data will
be written.header - an optional header for the zip file.uncompressedAlignment - the requested alignment of uncompressed data.java.io.IOExceptionpublic ZipOutput(java.io.OutputStream outputStream,
byte[] header,
int uncompressedAlignment,
java.lang.String comment)
throws java.io.IOException
outputStream - the output stream to which the zip data will be written.header - an optional header for the zip file.uncompressedAlignment - the requested alignment of uncompressed data.comment - optional comment for the entire zip file.java.io.IOExceptionpublic ZipOutput(java.io.DataOutputStream outputStream,
byte[] header,
int uncompressedAlignment,
java.lang.String comment)
throws java.io.IOException
outputStream - the output stream to which the zip data will be written.header - an optional header for the zip file.uncompressedAlignment - the requested alignment of uncompressed data.comment - optional comment for the entire zip file.java.io.IOExceptionpublic java.io.OutputStream createOutputStream(java.lang.String name,
boolean compress,
int modificationTime)
throws java.io.IOException
name - the name of the zip entry.compress - specifies whether the entry should be
compressed with the default
alignment.modificationTime - the modification date and time of the zip
entry, in DOS format.java.io.IOExceptionpublic java.io.OutputStream createOutputStream(java.lang.String name,
boolean compress,
int uncompressedAlignment,
int modificationTime)
throws java.io.IOException
name - the name of the zip entry.compress - specifies whether the entry should be
compressed.uncompressedAlignment - the requested alignment of uncompressed
data.modificationTime - the modification date and time of the zip
entry, in DOS format.java.io.IOExceptionpublic java.io.OutputStream createOutputStream(java.lang.String name,
boolean compress,
int uncompressedAlignment,
int modificationTime,
byte[] extraField,
java.lang.String comment)
throws java.io.IOException
name - the name of the zip entry.compress - specifies whether the entry should be
compressed.uncompressedAlignment - the requested alignment of uncompressed
data.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 - an optional comment.java.io.IOExceptionpublic void close()
throws java.io.IOException
java.io.IOExceptionpublic void close(long centralDirectoryOffset)
throws java.io.IOException
java.io.IOExceptionprotected long size()
protected long writeStartOfCentralDirectory()
protected long writeEntriesOfCentralDirectory()
throws java.io.IOException
java.io.IOExceptionprotected void writeEndOfCentralDirectory(long centralDirectoryOffset,
long centralDirectorySize)
throws java.io.IOException
centralDirectoryOffset - the offset of the central directory.centralDirectorySize - the size of the central directory, not
counting the empty header and the trailer.java.io.IOExceptionprotected void writeShort(int value)
throws java.io.IOException
java.io.IOExceptionprotected void writeInt(int value)
throws java.io.IOException
java.io.IOExceptionprotected void writeInt(long value)
throws java.io.IOException
java.io.IOExceptionprotected void writeLong(long value)
throws java.io.IOException
java.io.IOExceptionpublic static void main(java.lang.String[] args)