public class ZipEntry extends Object implements Cloneable
ZipFile.getInputStream(java.util.zip.ZipEntry). The class documentation for ZipInputStream and
ZipOutputStream shows how ZipEntry is used in conjunction with those two classes.| Modifier and Type | Field and Description |
|---|---|
static int |
CENATT |
static int |
CENATX |
static int |
CENCOM |
static int |
CENCRC |
static int |
CENDSK |
static int |
CENEXT |
static int |
CENFLG |
static int |
CENHDR |
static int |
CENHOW |
static int |
CENLEN |
static int |
CENNAM |
static int |
CENOFF |
static long |
CENSIG |
static int |
CENSIZ |
static int |
CENTIM |
static int |
CENVEM |
static int |
CENVER |
static int |
DEFLATED
Zip entry state: Deflated.
|
static int |
ENDCOM |
static int |
ENDHDR |
static int |
ENDOFF |
static long |
ENDSIG |
static int |
ENDSIZ |
static int |
ENDSUB |
static int |
ENDTOT |
static int |
EXTCRC |
static int |
EXTHDR |
static int |
EXTLEN |
static long |
EXTSIG |
static int |
EXTSIZ |
static int |
LOCCRC |
static int |
LOCEXT |
static int |
LOCFLG |
static int |
LOCHDR |
static int |
LOCHOW |
static int |
LOCLEN |
static int |
LOCNAM |
static long |
LOCSIG |
static int |
LOCSIZ |
static int |
LOCTIM |
static int |
LOCVER |
static int |
STORED
Zip entry state: Stored.
|
| Constructor and Description |
|---|
ZipEntry(String name)
Constructs a new
ZipEntry with the specified name. |
ZipEntry(String name,
String comment,
long crc,
long compressedSize,
long size,
int compressionMethod,
int time,
int modDate,
byte[] extra,
long localHeaderRelOffset,
long dataOffset) |
ZipEntry(ZipEntry ze)
Constructs a new
ZipEntry using the values obtained from ze. |
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Returns a deep copy of this zip entry.
|
String |
getComment()
Returns the comment for this
ZipEntry, or null if there is no comment. |
long |
getCompressedSize()
Gets the compressed size of this
ZipEntry. |
long |
getCrc()
Gets the checksum for this
ZipEntry. |
long |
getDataOffset() |
byte[] |
getExtra()
Gets the extra information for this
ZipEntry. |
int |
getMethod()
Gets the compression method for this
ZipEntry. |
String |
getName()
Gets the name of this
ZipEntry. |
long |
getSize()
Gets the uncompressed size of this
ZipEntry. |
long |
getTime()
Gets the last modification time of this
ZipEntry. |
int |
hashCode()
Returns the hash code for this
ZipEntry. |
boolean |
isDirectory()
Determine whether or not this
ZipEntry is a directory. |
void |
setComment(String comment)
Sets the comment for this
ZipEntry. |
void |
setCompressedSize(long value)
Sets the compressed size for this
ZipEntry. |
void |
setCrc(long value)
Sets the checksum for this
ZipEntry. |
void |
setDataOffset(long value) |
void |
setExtra(byte[] data)
Sets the extra information for this
ZipEntry. |
void |
setMethod(int value)
Sets the compression method for this entry to either
DEFLATED or STORED. |
void |
setSize(long value)
Sets the uncompressed size of this
ZipEntry. |
void |
setTime(long value)
Sets the modification time of this
ZipEntry. |
String |
toString()
Returns the string representation of this
ZipEntry. |
public static final int DEFLATED
public static final int STORED
public static final long LOCSIG
public static final long EXTSIG
public static final long CENSIG
public static final long ENDSIG
public static final int LOCHDR
public static final int EXTHDR
public static final int CENHDR
public static final int ENDHDR
public static final int LOCVER
public static final int LOCFLG
public static final int LOCHOW
public static final int LOCTIM
public static final int LOCCRC
public static final int LOCSIZ
public static final int LOCLEN
public static final int LOCNAM
public static final int LOCEXT
public static final int EXTCRC
public static final int EXTSIZ
public static final int EXTLEN
public static final int CENVEM
public static final int CENVER
public static final int CENFLG
public static final int CENHOW
public static final int CENTIM
public static final int CENCRC
public static final int CENSIZ
public static final int CENLEN
public static final int CENNAM
public static final int CENEXT
public static final int CENCOM
public static final int CENDSK
public static final int CENATT
public static final int CENATX
public static final int CENOFF
public static final int ENDSUB
public static final int ENDTOT
public static final int ENDSIZ
public static final int ENDOFF
public static final int ENDCOM
public ZipEntry(String name, String comment, long crc, long compressedSize, long size, int compressionMethod, int time, int modDate, byte[] extra, long localHeaderRelOffset, long dataOffset)
public ZipEntry(String name)
ZipEntry with the specified name. The name is actually a path,
and may contain / characters.IllegalArgumentException - if the name length is outside the range (> 0xFFFF).public ZipEntry(ZipEntry ze)
ZipEntry using the values obtained from ze.ze - the ZipEntry from which to obtain values.public String getComment()
ZipEntry, or null if there is no comment.
If we're reading a zip file using ZipInputStream, the comment is not available.public long getCompressedSize()
ZipEntry.public long getCrc()
ZipEntry.public byte[] getExtra()
ZipEntry.null if
there is none.public int getMethod()
ZipEntry.DEFLATED, STORED
or -1 if the compression method has not been set.public String getName()
ZipEntry.
Security note: Entry names can represent relative paths. foo/../bar or
../bar/baz, for example. If the entry name is being used to construct a filename
or as a path component, it must be validated or sanitized to ensure that files are not
written outside of the intended destination directory.
public long getSize()
ZipEntry.-1 if the size has not been
set.public long getTime()
ZipEntry.public boolean isDirectory()
ZipEntry is a directory.true when this ZipEntry is a directory, false otherwise.public void setComment(String comment)
ZipEntry.IllegalArgumentException - if the comment is >= 64 Ki UTF-8 bytes.public void setCompressedSize(long value)
ZipEntry.value - the compressed size (in bytes).public void setCrc(long value)
ZipEntry.value - the checksum for this entry.IllegalArgumentException - if value is < 0 or > 0xFFFFFFFFL.public void setExtra(byte[] data)
ZipEntry.IllegalArgumentException - if the data length >= 64 KiB.public void setMethod(int value)
DEFLATED or STORED.
The default is DEFLATED, which will cause the size, compressed size, and CRC to be
set automatically, and the entry's data to be compressed. If you switch to STORED
note that you'll have to set the size (or compressed size; they must be the same, but it's
okay to only set one) and CRC yourself because they must appear before the user data
in the resulting zip file. See setSize(long) and setCrc(long).IllegalArgumentException - when value is not DEFLATED or STORED.public void setSize(long value)
ZipEntry.value - the uncompressed size for this entry.IllegalArgumentException - if value < 0.public void setTime(long value)
ZipEntry.value - the modification time as the number of milliseconds since Jan.
1, 1970.public void setDataOffset(long value)
public long getDataOffset()
public String toString()
ZipEntry.public Object clone()
public int hashCode()
ZipEntry.hashCode in class ObjectObject.equals(java.lang.Object)