Class CompressionUtils


  • public class CompressionUtils
    extends java.lang.Object
    Compression utils class
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String TAR_GZ
      TAR GZ
      static java.lang.String TGZ
      TGZ
      static java.lang.String ZIP
      ZIP
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void extract​(java.io.File origin, java.io.File destination)
      Unzips a file depending on the extension
      static java.io.File newFile​(java.io.File destinationDir, java.util.zip.ZipEntry zipEntry)
      Creates a new file in the destination folder
      static void unTarFile​(java.io.File tarFile, java.io.File destFile)
      Unzips a file with tar
      static void unzipFolderZip4j​(java.nio.file.Path source, java.nio.file.Path target)
      Unzips a folder with Zip4j
      • Methods inherited from class java.lang.Object

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

      • CompressionUtils

        public CompressionUtils()
    • Method Detail

      • unzipFolderZip4j

        public static void unzipFolderZip4j​(java.nio.file.Path source,
                                            java.nio.file.Path target)
                                     throws java.io.IOException
        Unzips a folder with Zip4j
        Parameters:
        source - source path
        target - target path
        Throws:
        java.io.IOException - exception when file is not found
      • newFile

        public static java.io.File newFile​(java.io.File destinationDir,
                                           java.util.zip.ZipEntry zipEntry)
                                    throws java.io.IOException
        Creates a new file in the destination folder
        Parameters:
        destinationDir - destination folder
        zipEntry - zip file
        Returns:
        the newly created file
        Throws:
        java.io.IOException - throws an exception if the destination is outside of the target directory.
      • unTarFile

        public static void unTarFile​(java.io.File tarFile,
                                     java.io.File destFile)
        Unzips a file with tar
        Parameters:
        tarFile - tar file
        destFile - destination file
      • extract

        public static void extract​(java.io.File origin,
                                   java.io.File destination)
                            throws java.lang.Exception
        Unzips a file depending on the extension
        Parameters:
        origin - source file
        destination - destination folder
        Throws:
        java.lang.Exception - throws an exception if the file is not found