Class ZipExtensions


  • public final class ZipExtensions
    extends java.lang.Object
    The class ZipExtensions provides functionality for ziping and unzipping files.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void extractZipEntry​(java.util.zip.ZipFile zipFile, java.util.zip.ZipEntry target, java.io.File toDirectory)
      Extract zip entry.
      static boolean isZip​(java.lang.String filename)
      Checks if the given filename is a zip-file.
      static void unzip​(java.util.zip.ZipFile zipFile, java.io.File toDir)
      Unzip.
      static void zip​(java.io.File fileToZip, java.io.File zipFile)
      Zip the given file.
      static void zip​(java.io.File dirToZip, java.io.File zipFile, java.io.FilenameFilter filter)
      Zip the given file.
      static void zip​(java.io.File dirToZip, java.io.File zipFile, java.io.FilenameFilter filter, boolean createFile)
      Zip the given file.
      static void zipFiles​(java.io.File file, java.io.File dirToZip, java.io.FileFilter... excludeFileFilter)
      Zip files.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • extractZipEntry

        public static void extractZipEntry​(java.util.zip.ZipFile zipFile,
                                           java.util.zip.ZipEntry target,
                                           java.io.File toDirectory)
                                    throws java.io.IOException
        Extract zip entry.
        Parameters:
        zipFile - the zip file
        target - the target
        toDirectory - the to directory
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • isZip

        public static boolean isZip​(java.lang.String filename)
        Checks if the given filename is a zip-file.
        Parameters:
        filename - The filename to check.
        Returns:
        True if the filename is a zip-file otherwise false.
      • unzip

        public static void unzip​(java.util.zip.ZipFile zipFile,
                                 java.io.File toDir)
                          throws java.io.IOException
        Unzip.
        Parameters:
        zipFile - the zip file
        toDir - the to dir
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.
      • zip

        public static void zip​(java.io.File fileToZip,
                               java.io.File zipFile)
                        throws java.io.FileNotFoundException,
                               java.io.IOException,
                               FileDoesNotExistException
        Zip the given file.
        Parameters:
        fileToZip - the file to zip.
        zipFile - the zip file
        Throws:
        java.io.FileNotFoundException - the file not found exception
        java.io.IOException - Signals that an I/O exception has occurred.
        FileDoesNotExistException - the file does not exist exception
      • zip

        public static void zip​(java.io.File dirToZip,
                               java.io.File zipFile,
                               java.io.FilenameFilter filter)
                        throws java.io.FileNotFoundException,
                               java.io.IOException,
                               FileDoesNotExistException
        Zip the given file.
        Parameters:
        dirToZip - the dir to zip
        zipFile - the zip file
        filter - the filter
        Throws:
        java.io.FileNotFoundException - the file not found exception
        java.io.IOException - Signals that an I/O exception has occurred.
        FileDoesNotExistException - the file does not exist exception
      • zip

        public static void zip​(java.io.File dirToZip,
                               java.io.File zipFile,
                               java.io.FilenameFilter filter,
                               boolean createFile)
                        throws java.io.FileNotFoundException,
                               java.io.IOException,
                               FileDoesNotExistException
        Zip the given file.
        Parameters:
        dirToZip - the dir to zip
        zipFile - the zip file
        filter - the filter
        createFile - the create file
        Throws:
        java.io.FileNotFoundException - the file not found exception
        java.io.IOException - Signals that an I/O exception has occurred.
        FileDoesNotExistException - the file does not exist exception
      • zipFiles

        public static void zipFiles​(java.io.File file,
                                    java.io.File dirToZip,
                                    java.io.FileFilter... excludeFileFilter)
                             throws java.io.IOException
        Zip files.
        Parameters:
        file - the file
        dirToZip - the dir to zip
        excludeFileFilter - the file filter for files to exclude
        Throws:
        java.io.IOException - Signals that an I/O exception has occurred.