|
TrueZIP 6.8.2 | ||||||||
| 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
public class BasicZipOutputStream
This class is not intended for public use!
The methods in this class are unsynchronized and
entries/getEntry(java.lang.String) enumerate/return ZipEntry
instances which are shared with this class rather than clones of them.
This is used within TrueZIP in order to benefit from the slightly better
performance.
ZipOutputStream| Nested Class Summary | |
|---|---|
private static class |
BasicZipOutputStream.ZipDeflater
A Deflater which can be asked for its current deflation level and counts input and output data length as a long integer value. |
| Field Summary | |
|---|---|
private long |
cdOffset
Start of central directory. |
private String |
charset
The charset to use for entry names and comments. |
private boolean |
closed
|
private String |
comment
The file comment. |
private CRC32 |
crc
CRC instance to avoid parsing DEFLATED data twice. |
private long |
dataStart
Start of entry data. |
private byte[] |
dbuf
This buffer holds deflated data for output. |
private BasicZipOutputStream.ZipDeflater |
def
This instance is used for deflated output. |
static String |
DEFAULT_CHARSET
The default character set used for entry names and comments in ZIP compatible files. |
private boolean |
deflate
Whether or not we need to deflate the current entry. |
private Map |
entries
The list of ZIP entries started to be written so far. |
private ZipEntry |
entry
Current entry. |
private boolean |
finished
|
private short |
method
Default compression method for next entry. |
private byte[] |
sbuf
|
| Fields inherited from class java.io.FilterOutputStream |
|---|
out |
| Constructor Summary | |
|---|---|
BasicZipOutputStream(OutputStream out)
Creates a new ZIP output stream decorating the given output stream, using the "UTF-8" charset. |
|
BasicZipOutputStream(OutputStream out,
String charset)
Creates a new ZIP output stream decorating the given output stream. |
|
| Method Summary | |
|---|---|
private static void |
checkLocalFileHeaderData(ZipEntry entry)
|
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. |
private void |
deflate()
|
Enumeration |
entries()
Returns an enumeration 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. |
String |
getEncoding()
Returns the charset to use for filenames and the file comment. |
ZipEntry |
getEntry(String name)
Returns 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)
Equivalent to putNextEntry(entry, true). |
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. |
private static LEDataOutputStream |
toLEDataOutputStream(OutputStream out)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
private void |
writeCentralFileHeader(ZipEntry entry)
Writes a Central File Header record. |
private void |
writeDataDescriptor()
|
private void |
writeEndOfCentralDirectory()
Writes the End Of Central Directory record. |
private void |
writeLocalFileHeader()
|
| 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 |
| Field Detail |
|---|
public static final String DEFAULT_CHARSET
private final String charset
private final CRC32 crc
private final BasicZipOutputStream.ZipDeflater def
private final byte[] dbuf
private final byte[] sbuf
private String comment
private short method
private final Map entries
private long dataStart
private long cdOffset
private boolean finished
private boolean closed
private ZipEntry entry
private boolean deflate
DEFLATED method to
write already compressed entry data into the ZIP file.
| Constructor Detail |
|---|
public BasicZipOutputStream(OutputStream out)
throws NullPointerException
NullPointerException - If out is null.
public BasicZipOutputStream(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 |
|---|
private static LEDataOutputStream toLEDataOutputStream(OutputStream out)
public String getEncoding()
public int size()
public Enumeration entries()
public ZipEntry getEntry(String name)
ZipEntry for the given name or
null if no entry with that name exists.
Note that the returned entry is shared with this class.
It is illegal to change its state!
name - Name of the ZIP entry.public String getComment()
public void setComment(String comment)
public int getLevel()
public void setLevel(int level)
public int getMethod()
ZipEntry does not specify a
compression method.
setMethod(int),
ZipEntry.getMethod()public void setMethod(int method)
ZipEntry does not specify a
compression method.
Legal values are ZipEntry.STORED (uncompressed) and
ZipEntry.DEFLATED (compressed).
The initial value is ZipEntry.DEFLATED.
getMethod(),
ZipEntry.setMethod(int)public long length()
public boolean isBusy()
true if and only if this
BasicZipOutputStream is currently writing a ZIP entry.
public final void putNextEntry(ZipEntry entry)
throws IOException
putNextEntry(entry, true).
IOException
public void putNextEntry(ZipEntry entry,
boolean deflate)
throws IOException
java.util.zip.ZipOutputStream which would throw a ZipException
in this method when the second entry with the same name is to be written.
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.
private static void checkLocalFileHeaderData(ZipEntry entry)
throws ZipException
ZipException
private void writeLocalFileHeader()
throws IOException
IOException - On any I/O related issue.
public void write(int b)
throws IOException
write in class FilterOutputStreamIOException - On any I/O related issue.
public void write(byte[] b,
int off,
int len)
throws IOException
write in class FilterOutputStreamIOException - On any I/O related issue.
private void deflate()
throws IOException
IOException
public void closeEntry()
throws IOException
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.
private void writeDataDescriptor()
throws IOException
IOException - On any I/O related issue.
public void finish()
throws IOException
Notes:
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.
private void writeCentralFileHeader(ZipEntry entry)
throws IOException
IOException - On any I/O related issue.
private void writeEndOfCentralDirectory()
throws IOException
IOException - On any I/O related issue.
public void close()
throws IOException
close in interface Closeableclose in class FilterOutputStreamIOException - On any I/O related issue.
|
TrueZIP 6.8.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||