Class ZipUtils


  • public class ZipUtils
    extends Object
    Utilities for Zip and UnZip operations. Provide Zip utility for usage across the application to Zip and unZip Files and Directory Size of the files and Folders according to business needs This ZipUtil will not applicable for RAR or 7Z etc.
    Since:
    1.0.0
    Author:
    Megha Tanga
    • Method Detail

      • zipByteArray

        public static byte[] zipByteArray​(byte[] input)
                                   throws IOException
        Method used for zipping a Byte Array
        Parameters:
        input - pass Byte Array want to zip it
        Returns:
        zipped Byte Array
        Throws:
        IOException - when file unable to read
      • unzipByteArray

        public static byte[] unzipByteArray​(byte[] input)
                                     throws IOException
        Method used for unzipping a zipped Byte Array
        Parameters:
        input - pass zipped Byte Array want to unzip it
        Returns:
        returned unzipped Byte Array
        Throws:
        IOException - when file unable to read
        DataFormatException - Attempting to unzip file that is not zipped
        See Also:
        IOException
      • unZipDirectory

        public static boolean unZipDirectory​(String zipFilePath,
                                             String destDirectory)
                                      throws Exception
        Extracts a zip file specified by the zipFilePath to a directory specified by destDirectory (will be created if does not exists)
        Parameters:
        zipFilePath - input zipped directory example: zipFilePath = "D:\\Testfiles\\test.zip";
        destDirectory - output unziped Directory example : outputUnZipDir = "D:\\Testfiles\\unZipDir";
        Returns:
        true zip file extracted in given directory
        Throws:
        FileNotFoundException - when file is not found
        IOException - when file unable to read
        Exception