类 ZipEntry

java.lang.Object
java.util.zip.ZipEntry
com.sh.common.zip.ZipEntry
所有已实现的接口:
Cloneable

public class ZipEntry extends ZipEntry implements Cloneable
Extension that adds better handling of extra fields and provides access to the internal and external file attributes.

The extra data is expected to follow the recommendation of the .ZIP File Format Specification created by PKWARE Inc. :

  • the extra byte array consists of a sequence of extra fields
  • each extra fields starts by a two byte header id followed by a two byte sequence holding the length of the remainder of data.

Any extra data that cannot be parsed by the rules above will be consumed as "unparseable" extra data and treated differently by the methods of this class. Versions prior to Apache Commons Compress 1.1 would have thrown an exception if any attempt was made to read or write extra data not conforming to the recommendation.

另请参阅:
  • 字段详细资料

  • 构造器详细资料

    • ZipEntry

      public ZipEntry(String name)
      Creates a new zip entry with the specified name.
      参数:
      name - the name of the entry
      从以下版本开始:
      1.1
    • ZipEntry

      public ZipEntry(ZipEntry entry) throws ZipException
      Creates a new zip entry with fields taken from the specified zip entry.
      参数:
      entry - the entry to get fields from
      抛出:
      ZipException - on error
      从以下版本开始:
      1.1
    • ZipEntry

      public ZipEntry(ZipEntry entry) throws ZipException
      Creates a new zip entry with fields taken from the specified zip entry.
      参数:
      entry - the entry to get fields from
      抛出:
      ZipException - on error
      从以下版本开始:
      1.1
    • ZipEntry

      protected ZipEntry()
      从以下版本开始:
      1.9
  • 方法详细资料

    • clone

      public Object clone()
      Overwrite clone.
      覆盖:
      clone 在类中 ZipEntry
      返回:
      a cloned copy of this ZipEntry
      从以下版本开始:
      1.1
    • getInternalAttributes

      public int getInternalAttributes()
      Retrieves the internal file attributes.
      返回:
      the internal file attributes
      从以下版本开始:
      1.1
    • setInternalAttributes

      public void setInternalAttributes(int value)
      Sets the internal file attributes.
      参数:
      value - an int value
      从以下版本开始:
      1.1
    • getExternalAttributes

      public long getExternalAttributes()
      Retrieves the external file attributes.
      返回:
      the external file attributes
      从以下版本开始:
      1.1
    • setExternalAttributes

      public void setExternalAttributes(long value)
      Sets the external file attributes.
      参数:
      value - an long value
      从以下版本开始:
      1.1
    • setUnixMode

      public void setUnixMode(int mode)
      Sets Unix permissions in a way that is understood by Info-Zip's unzip command.
      参数:
      mode - an int value
      从以下版本开始:
      Ant 1.5.2
    • getUnixMode

      public int getUnixMode()
      Unix permission.
      返回:
      the unix permissions
      从以下版本开始:
      Ant 1.6
    • getPlatform

      public int getPlatform()
      Platform specification to put into the "version made by" part of the central file header.
      返回:
      PLATFORM_FAT unless setUnixMode has been called, in which case PLATORM_UNIX will be returned.
      从以下版本开始:
      Ant 1.5.2
    • setPlatform

      protected void setPlatform(int platform)
      Set the platform (UNIX or FAT).
      参数:
      platform - an int value - 0 is FAT, 3 is UNIX
      从以下版本开始:
      1.9
    • setExtraFields

      public void setExtraFields(ZipExtraField[] fields)
      Replaces all currently attached extra fields with the new array.
      参数:
      fields - an array of extra fields
      从以下版本开始:
      1.1
    • getExtraFields

      public ZipExtraField[] getExtraFields()
      Retrieves all extra fields that have been parsed successfully.
      返回:
      an array of the extra fields
    • getExtraFields

      public ZipExtraField[] getExtraFields(boolean includeUnparseable)
      Retrieves extra fields.
      参数:
      includeUnparseable - whether to also return unparseable extra fields as UnparseableExtraFieldData if such data exists.
      返回:
      an array of the extra fields
      从以下版本开始:
      1.1
    • addExtraField

      public void addExtraField(ZipExtraField ze)
      Adds an extra field - replacing an already present extra field of the same type.

      If no extra field of the same type exists, the field will be added as last field.

      参数:
      ze - an extra field
      从以下版本开始:
      1.1
    • addAsFirstExtraField

      public void addAsFirstExtraField(ZipExtraField ze)
      Adds an extra field - replacing an already present extra field of the same type.

      The new extra field will be the first one.

      参数:
      ze - an extra field
      从以下版本开始:
      1.1
    • removeExtraField

      public void removeExtraField(ZipShort type)
      Remove an extra field.
      参数:
      type - the type of extra field to remove
      从以下版本开始:
      1.1
    • removeUnparseableExtraFieldData

      public void removeUnparseableExtraFieldData()
      Removes unparseable extra field data.
    • getExtraField

      public ZipExtraField getExtraField(ZipShort type)
      Looks up an extra field by its header id.
      参数:
      type - ZipShort
      返回:
      null if no such field exists.
    • getUnparseableExtraFieldData

      public UnparseableExtraFieldData getUnparseableExtraFieldData()
      Looks up extra field data that couldn't be parsed correctly.
      返回:
      null if no such field exists.
    • setExtra

      public void setExtra(byte[] extra) throws RuntimeException
      Parses the given bytes as extra field data and consumes any unparseable data as an UnparseableExtraFieldData instance.
      覆盖:
      setExtra 在类中 ZipEntry
      参数:
      extra - an array of bytes to be parsed into extra fields
      抛出:
      RuntimeException - if the bytes cannot be parsed
      RuntimeException - on error
      从以下版本开始:
      1.1
    • setExtra

      protected void setExtra()
      Unfortunately java.util.zip.ZipOutputStream seems to access the extra data directly, so overriding getExtra doesn't help - we need to modify super's data directly.
      从以下版本开始:
      1.1
    • setCentralDirectoryExtra

      public void setCentralDirectoryExtra(byte[] b)
      Sets the central directory part of extra fields.
      参数:
      b - byte[]
    • getLocalFileDataExtra

      public byte[] getLocalFileDataExtra()
      Retrieves the extra data for the local file data.
      返回:
      the extra data for local file
      从以下版本开始:
      1.1
    • getCentralDirectoryExtra

      public byte[] getCentralDirectoryExtra()
      Retrieves the extra data for the central directory.
      返回:
      the central directory extra data
      从以下版本开始:
      1.1
    • setComprSize

      public void setComprSize(long size)
      Make this class work in JDK 1.1 like a 1.2 class.

      This either stores the size for later usage or invokes setCompressedSize via reflection.

      参数:
      size - the size to use Use setCompressedSize directly.
      从以下版本开始:
      1.2
    • getName

      public String getName()
      Get the name of the entry.
      覆盖:
      getName 在类中 ZipEntry
      返回:
      the entry name
      从以下版本开始:
      1.9
    • isDirectory

      public boolean isDirectory()
      Is this entry a directory?
      覆盖:
      isDirectory 在类中 ZipEntry
      返回:
      true if the entry is a directory
      从以下版本开始:
      1.10
    • setName

      protected void setName(String name)
      Set the name of the entry.
      参数:
      name - the name to use
    • hashCode

      public int hashCode()
      Get the hashCode of the entry. This uses the name as the hashcode.
      覆盖:
      hashCode 在类中 ZipEntry
      返回:
      a hashcode.
      从以下版本开始:
      Ant 1.7
    • equals

      public boolean equals(Object o)
      The equality method. In this case, the implementation returns 'this == o' which is basically the equals method of the Object class.
      覆盖:
      equals 在类中 Object
      参数:
      o - the object to compare to
      返回:
      true if this object is the same as o
      从以下版本开始:
      Ant 1.7