|
TrueZIP Driver ZIP 7.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.truezip.zip.RawZipFile<ZipEntry>
de.schlichtherle.truezip.zip.ZipFile
public class ZipFile
Drop-in replacement for java.util.zip.ZipFile.
Where the constructors of this class accept a charset
parameter, this is used to decode comments and entry names in the ZIP file.
However, if an entry has bit 11 set in its General Purpose Bit Flag,
then this parameter is ignored and "UTF-8" is used for this entry.
This is in accordance to Appendix D of PKWARE's ZIP File Format
Specification, version 6.3.0 and later.
This class is able to skip a preamble like the one found in self extracting archives.
Note that the entries returned by this class are instances of
de.schlichtherle.truezip.io.zip.ZipEntry instead of
java.util.zip.ZipEntry.
This class is thread-safe.
ZipOutputStream| Nested Class Summary | |
|---|---|
private static class |
ZipFile.DefaultReadOnlyFilePool
A pool which allocates DefaultReadOnlyFile objects for the
provided to its constructor. |
| Nested classes/interfaces inherited from class de.schlichtherle.truezip.zip.RawZipFile |
|---|
RawZipFile.OffsetMapper |
| Field Summary | |
|---|---|
private String |
name
|
| Fields inherited from class de.schlichtherle.truezip.zip.RawZipFile |
|---|
DEFAULT_CHARSET |
| Constructor Summary | |
|---|---|
ZipFile(File file)
Equivalent to ZipFile(file, DEFAULT_CHARSET, true, false) |
|
ZipFile(File file,
Charset charset)
Equivalent to ZipFile(file, charset, true, false) |
|
ZipFile(File file,
Charset charset,
boolean preambled,
boolean postambled)
Opens the given File for reading its entries. |
|
ZipFile(ReadOnlyFile rof)
Equivalent to ZipFile(rof, DEFAULT_CHARSET, true, false) |
|
ZipFile(ReadOnlyFile rof,
Charset charset)
Equivalent to ZipFile(rof, charset, true, false) |
|
ZipFile(ReadOnlyFile rof,
Charset charset,
boolean preambled,
boolean postambled)
Opens the given ReadOnlyFile for reading its entries. |
|
ZipFile(String path)
Equivalent to ZipFile(name, DEFAULT_CHARSET, true, false) |
|
ZipFile(String path,
Charset charset)
Equivalent to ZipFile(name, charset, true, false) |
|
ZipFile(String path,
Charset charset,
boolean preambled,
boolean postambled)
Opens the ZIP file identified by the given path name for reading its entries. |
|
| Method Summary | |
|---|---|
boolean |
busy()
Returns true if and only if some input streams are busy with
reading from this ZIP file. |
void |
close()
Closes the file. |
Enumeration<? extends ZipEntry> |
entries()
Enumerates clones of all entries in this ZIP file. |
ZipEntry |
getEntry(String name)
Returns a clone of the entry for the given name or null if no
entry with this name exists. |
protected InputStream |
getInputStream(String name,
boolean check,
boolean inflate)
Returns an InputStream for reading the inflated or
deflated data of the given entry. |
String |
getName()
Returns the string representation of whatever
input source object was used to construct this ZIP file. |
InputStream |
getPostambleInputStream()
Returns an InputStream to read the postamble of this ZIP file. |
InputStream |
getPreambleInputStream()
Returns an InputStream to read the preamble of this ZIP file. |
Iterator<ZipEntry> |
iterator()
Iterates through clones for all entries in this ZIP file. |
| Methods inherited from class de.schlichtherle.truezip.zip.RawZipFile |
|---|
assertOpen, getCharset, getCheckedInputStream, getCheckedInputStream, getComment, getInputStream, getInputStream, getOffsetMapper, getPostambleLength, getPreambleLength, length, offsetsConsiderPreamble, size |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final String name
| Constructor Detail |
|---|
public ZipFile(String path)
throws IOException
ZipFile(name, DEFAULT_CHARSET, true, false)
IOException
public ZipFile(String path,
Charset charset)
throws IOException
ZipFile(name, charset, true, false)
IOException
public ZipFile(String path,
Charset charset,
boolean preambled,
boolean postambled)
throws IOException
path - the path name of the file.charset - the charset to use for decoding entry names and ZIP file
comment.preambled - if this is true, then the ZIP file may have a
preamble.
Otherwise, the ZIP file must start with either a Local File
Header (LFH) signature or an End Of Central Directory (EOCD)
Header, causing this constructor to fail if the file is actually
a false positive ZIP file, i.e. not compatible to the ZIP File
Format Specification.
This may be useful to read Self Extracting ZIP files (SFX), which
usually contain the application code required for extraction in
the preamble.postambled - if this is true, then the ZIP file may have a
postamble of arbitrary length.
Otherwise, the ZIP file must not have a postamble which exceeds
64KB size, including the End Of Central Directory record
(i.e. including the ZIP file comment), causing this constructor
to fail if the file is actually a false positive ZIP file, i.e.
not compatible to the ZIP File Format Specification.
This may be useful to read Self Extracting ZIP files (SFX) with
large postambles.
NullPointerException - if any reference parameter is null.
FileNotFoundException - if name cannot get opened for
reading.
ZipException - if name is not compatible with the ZIP
File Format Specification.
IOException - on any other I/O related issue.
public ZipFile(File file)
throws IOException
ZipFile(file, DEFAULT_CHARSET, true, false)
IOException
public ZipFile(File file,
Charset charset)
throws IOException
ZipFile(file, charset, true, false)
IOException
public ZipFile(File file,
Charset charset,
boolean preambled,
boolean postambled)
throws IOException
File for reading its entries.
file - the file.charset - the charset to use for decoding entry names and ZIP file
comment.preambled - if this is true, then the ZIP file may have a
preamble.
Otherwise, the ZIP file must start with either a Local File
Header (LFH) signature or an End Of Central Directory (EOCD)
Header, causing this constructor to fail if the file is actually
a false positive ZIP file, i.e. not compatible to the ZIP File
Format Specification.
This may be useful to read Self Extracting ZIP files (SFX), which
usually contain the application code required for extraction in
the preamble.postambled - if this is true, then the ZIP file may have a
postamble of arbitrary length.
Otherwise, the ZIP file must not have a postamble which exceeds
64KB size, including the End Of Central Directory record
(i.e. including the ZIP file comment), causing this constructor
to fail if the file is actually a false positive ZIP file, i.e.
not compatible to the ZIP File Format Specification.
This may be useful to read Self Extracting ZIP files (SFX) with
large postambles.
NullPointerException - if any reference parameter is null.
FileNotFoundException - if file cannot get opened for
reading.
ZipException - if file is not compatible with the ZIP
File Format Specification.
IOException - on any other I/O related issue.
public ZipFile(ReadOnlyFile rof)
throws IOException
ZipFile(rof, DEFAULT_CHARSET, true, false)
IOException
public ZipFile(ReadOnlyFile rof,
Charset charset)
throws IOException
ZipFile(rof, charset, true, false)
IOException
public ZipFile(ReadOnlyFile rof,
Charset charset,
boolean preambled,
boolean postambled)
throws IOException
ReadOnlyFile for reading its entries.
rof - the random access read only file.charset - the charset to use for decoding entry names and ZIP file
comment.preambled - if this is true, then the ZIP file may have a
preamble.
Otherwise, the ZIP file must start with either a Local File
Header (LFH) signature or an End Of Central Directory (EOCD)
Header, causing this constructor to fail if the file is actually
a false positive ZIP file, i.e. not compatible to the ZIP File
Format Specification.
This may be useful to read Self Extracting ZIP files (SFX), which
usually contain the application code required for extraction in
the preamble.postambled - if this is true, then the ZIP file may have a
postamble of arbitrary length.
Otherwise, the ZIP file must not have a postamble which exceeds
64KB size, including the End Of Central Directory record
(i.e. including the ZIP file comment), causing this constructor
to fail if the file is actually a false positive ZIP file, i.e.
not compatible to the ZIP File Format Specification.
This may be useful to read Self Extracting ZIP files (SFX) with
large postambles.
NullPointerException - if any reference parameter is null.
FileNotFoundException - if rof cannot get opened for
reading.
ZipException - if rof is not compatible with the ZIP
File Format Specification.
IOException - on any other I/O related issue.| Method Detail |
|---|
public String getName()
string representation of whatever
input source object was used to construct this ZIP file.
For String and File objects, this is a path name.
public Enumeration<? extends ZipEntry> entries()
iterator()public Iterator<ZipEntry> iterator()
iterator in interface Iterable<ZipEntry>iterator in class RawZipFile<ZipEntry>public ZipEntry getEntry(String name)
null if no
entry with this name exists.
getEntry in class RawZipFile<ZipEntry>name - the name of the ZIP entry.
public InputStream getPreambleInputStream()
throws IOException
RawZipFileInputStream to read the preamble of this ZIP file.
Note that the returned stream is a lightweight stream,
i.e. there is no external resource such as a ReadOnlyFile
allocated for it. Instead, all streams returned by this method share
the underlying ReadOnlyFile of this ZipFile.
This allows to close this object (and hence the underlying
ReadOnlyFile) without cooperation of the returned
streams, which is important if the client application wants to work on
the underlying file again (e.g. update or delete it).
getPreambleInputStream in class RawZipFile<ZipEntry>ZipException - If this ZIP file has been closed.
IOException
public InputStream getPostambleInputStream()
throws IOException
RawZipFileInputStream to read the postamble of this ZIP file.
Note that the returned stream is a lightweight stream,
i.e. there is no external resource such as a ReadOnlyFile
allocated for it. Instead, all streams returned by this method share
the underlying ReadOnlyFile of this ZipFile.
This allows to close this object (and hence the underlying
ReadOnlyFile) without cooperation of the returned
streams, which is important if the client application wants to work on
the underlying file again (e.g. update or delete it).
getPostambleInputStream in class RawZipFile<ZipEntry>ZipException - If this ZIP file has been closed.
IOExceptionpublic boolean busy()
RawZipFiletrue if and only if some input streams are busy with
reading from this ZIP file.
busy in class RawZipFile<ZipEntry>
protected InputStream getInputStream(String name,
boolean check,
boolean inflate)
throws IOException
RawZipFileInputStream for reading the inflated or
deflated data of the given entry.
If the RawZipFile.close() method is called on this instance, all input
streams returned by this method are closed, too.
getInputStream in class RawZipFile<ZipEntry>name - The name of the entry to get the stream for
- may not be null!check - Whether or not the entry's CRC-32 value is checked.
If and only if this parameter is true, two additional checks are
performed for the ZIP entry:
InputStream.close() on the returned entry
stream, the CRC-32 value computed from the inflated entry
data is checked against the declared CRC-32 values.
This is independent from the inflate parameter.
CRC32Exception is thrown.
This parameter should be false for most
applications, and is the default for the sibling of this class
in java.util.zip.ZipFile.
inflate - Whether or not the entry data should be inflated.
If false, the entry data is not inflated,
even if the entry data is deflated.
This parameter should be true for most applications.
null if the
entry does not exist.
CRC32Exception - If the declared CRC-32 values of the inflated
entry data are inconsistent across the entry headers.
ZipException - If this file is not compatible to the ZIP File
Format Specification.
IOException - If the entry cannot get read from this ZipFile.
public void close()
throws IOException
RawZipFile
close in interface Closeableclose in class RawZipFile<ZipEntry>IOException - if an error occurs closing the file.
|
TrueZIP Driver ZIP 7.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||