Class CompressionUtilities


  • public class CompressionUtilities
    extends Object
    Utilities class to zip and unzip folders.
    Since:
    0.7.0
    Author:
    Andrea Antonello (www.hydrologis.com)
    • Constructor Detail

      • CompressionUtilities

        public CompressionUtilities()
    • Method Detail

      • zipFolder

        public static void zipFolder​(String srcFolder,
                                     String destZipFile,
                                     boolean addBaseFolder)
                              throws IOException
        Compress a folder and its contents.
        Parameters:
        srcFolder - path to the folder to be compressed.
        destZipFile - path to the final output zip file.
        addBaseFolder - flag to decide whether to add also the provided base (srcFolder) folder or not.
        Throws:
        IOException
      • zipFiles

        public static void zipFiles​(File[] srcFiles,
                                    String destZipFile)
                             throws IOException
        Compress a set of files and its contents if folders.
        Parameters:
        srcFiles - the files to compress.
        destZipFile - path to the final output zip file.
        Throws:
        IOException
      • unzipFolder

        public static String unzipFolder​(String zipFile,
                                         String destFolder,
                                         boolean addTimeStamp)
                                  throws IOException
        Uncompress a compressed file to the contained structure.
        Parameters:
        zipFile - the zip file that needs to be unzipped
        destFolder - the folder into which unzip the zip file and create the folder structure
        addTimeStamp - if true, the timestamp is added if the base folder already exists.
        Returns:
        the name of the internal base folder or null.
        Throws:
        IOException