Class Zips


  • public class Zips
    extends Object
    Utility class to work with Zip files (Path based).
    • Constructor Detail

      • Zips

        public Zips()
    • Method Detail

      • unpackZip

        public static int unpackZip​(Path source,
                                    Path outputDir)
                             throws IOException
        Unzip the given source Zip file in the outputDir.
        Parameters:
        source - the file to unzip.
        outputDir - the output directory where the Zip will be unpacked.
        Returns:
        the number of unpacked entries
        Throws:
        IOException
      • unpackJar

        public static int unpackJar​(Path source,
                                    Path outputDir)
                             throws IOException
        Unzip the given source Jar file in the outputDir.
        Parameters:
        source - the file to unzip.
        outputDir - the output directory where the Jar will be unpacked. It does not have to exist beforehand.
        Returns:
        the number of unpacked entries
        Throws:
        IOException
      • packZip

        public static int packZip​(Path source,
                                  Path targetZip,
                                  boolean preserveRoot)
                           throws IOException
        Zip the given source file or folder in the targetZip Zip file. If preserveRoot is set to true, the output Zip will contain the folder and its contents, only its contents otherwise.
        Parameters:
        source - the folder to zip.
        targetZip - the Zip file to create or overwrite.
        preserveRoot - whether the source folder should be kept in the target Zip.
        Returns:
        the number of packed entries
        Throws:
        IOException
      • packJar

        public static int packJar​(Path source,
                                  Path targetJar,
                                  boolean preserveRoot)
                           throws IOException
        Zip the given source file or folder in the targetJar Jar file. If preserveRoot is set to true, the output Zip will contain the folder and its contents, only its contents otherwise.
        Parameters:
        source - the folder to zip.
        targetJar - the Jar file to create or overwrite.
        preserveRoot - whether the source folder should be kept in the target Jar.
        Returns:
        the number of packed entries
        Throws:
        IOException