Class ZipEntryUtil

java.lang.Object
org.zeroturnaround.zip.ZipEntryUtil

class ZipEntryUtil extends Object
Util class for static methods shared between ZipUtil and Zips.
  • Constructor Details

    • ZipEntryUtil

      private ZipEntryUtil()
  • Method Details

    • copy

      static ZipEntry copy(ZipEntry original)
      Copy entry
      Parameters:
      original - - zipEntry to copy
      Returns:
      copy of the original entry
    • copy

      static ZipEntry copy(ZipEntry original, String newName)
      Copy entry with another name.
      Parameters:
      original - - zipEntry to copy
      newName - - new entry name, optional, if null, ogirinal's entry
      Returns:
      copy of the original entry, but with the given name
    • copyEntry

      static void copyEntry(ZipEntry zipEntry, InputStream in, ZipOutputStream out) throws IOException
      Copies a given ZIP entry to a ZIP file.
      Parameters:
      zipEntry - a ZIP entry from existing ZIP file.
      in - contents of the ZIP entry.
      out - target ZIP stream.
      Throws:
      IOException
    • copyEntry

      static void copyEntry(ZipEntry originalEntry, InputStream in, ZipOutputStream out, boolean preserveTimestamps) throws IOException
      Copies a given ZIP entry to a ZIP file. If this.preserveTimestamps is true, original timestamp is carried over, otherwise uses current time.
      Parameters:
      originalEntry - a ZIP entry from existing ZIP file.
      in - contents of the ZIP entry.
      out - target ZIP stream.
      Throws:
      IOException
    • addEntry

      static void addEntry(ZipEntry zipEntry, InputStream in, ZipOutputStream out) throws IOException
      Adds a given ZIP entry to a ZIP file.
      Parameters:
      zipEntry - new ZIP entry.
      in - contents of the ZIP entry.
      out - target ZIP stream.
      Throws:
      IOException
    • fromFile

      static ZipEntry fromFile(String name, File file)
      Create new Zip entry and fill it with associated with file meta-info
      Parameters:
      name - Zip entry name
      file - source File
      Returns:
      newly created Zip entry
    • setZTFilePermissions

      static boolean setZTFilePermissions(ZipEntry zipEntry, ZTFilePermissions permissions)
      Add file permissions info to ZIP entry. Current implementation adds "ASi Unix" (tag 0x756e) extra block to entry.
      Parameters:
      zipEntry - ZIP entry
      permissions - permissions to assign
    • getZTFilePermissions

      static ZTFilePermissions getZTFilePermissions(ZipEntry zipEntry)
      Get assigned to ZIP entry file permissions info. Current implementation tries to read "ASi Unix" (tag 0x756e) extra tag. "ASi Unix"
      Parameters:
      zipEntry -
      Returns:
      file permissions info or null if ZIP entry does not have "ASi Unix" extra field.
    • getFirstAsiExtraField

      private static AsiExtraField getFirstAsiExtraField(List<ZipExtraField> fields)