Class ZipUtils


  • public class ZipUtils
    extends Object
    This class contains static utility methods for zip files.
    • Constructor Detail

      • ZipUtils

        public ZipUtils()
    • Method Detail

      • unzip

        public static void unzip​(File zipFile,
                                 File outputDir)
                          throws IOException
        Unzips a zip file to the specified output directory.
        Parameters:
        zipFile - the zip file
        outputDir - the output directory
        Throws:
        IOException - if a reading or writing error occurs
      • zipFile

        public static void zipFile​(File srcFile,
                                   File zipFile)
                            throws IOException
        Creates a ZIP file containing only the specified source file.
        Parameters:
        srcFile - the source file
        zipFile - the ZIP file
        Throws:
        IOException - if a reading or writing error occurs
      • zipFileSet

        public static void zipFileSet​(File rootDir,
                                      List<File> files,
                                      File zipFile)
                               throws IOException
        Creates a ZIP file containing a specified set of files within a root directory. The root directory is used to obtain the relative path to each file in the set. The relative paths are stored in the ZIP file.
        Parameters:
        rootDir - the root directory
        files - the files to add to the ZIP file
        zipFile - the ZIP file
        Throws:
        IOException - if a reading or writing error occurs