Class TarGzCompressionUtils


  • public class TarGzCompressionUtils
    extends Object
    Utility class to compress/de-compress tar.gz files.
    • Method Detail

      • createTarGzFile

        public static void createTarGzFile​(File inputFile,
                                           File outputFile)
                                    throws IOException
        Creates a tar.gz file from the input file/directory to the output file. The output file must have ".tar.gz" as the file extension.
        Throws:
        IOException
      • createTarGzFile

        public static void createTarGzFile​(File[] inputFiles,
                                           File outputFile)
                                    throws IOException
        Creates a tar.gz file from a list of input file/directories to the output file. The output file must have ".tar.gz" as the file extension.
        Throws:
        IOException
      • untar

        public static List<File> untar​(File inputFile,
                                       File outputDir)
                                throws IOException
        Un-tars a tar.gz file into a directory, returns all the untarred files/directories.

        For security reason, the untarred files must reside in the output directory.

        Throws:
        IOException
      • untar

        public static List<File> untar​(InputStream inputStream,
                                       File outputDir)
                                throws IOException
        Un-tars an inputstream of a tar.gz file into a directory, returns all the untarred files/directories.

        For security reason, the untarred files must reside in the output directory.

        Throws:
        IOException
      • untarWithRateLimiter

        public static List<File> untarWithRateLimiter​(InputStream inputStream,
                                                      File outputDir,
                                                      long maxStreamRateInByte)
                                               throws IOException
        Un-tars an inputstream of a tar.gz file into a directory, returns all the untarred files/directories. RateLimit limits the untar rate

        For security reason, the untarred files must reside in the output directory.

        Throws:
        IOException
      • untarOneFile

        public static void untarOneFile​(File inputFile,
                                        String fileName,
                                        File outputFile)
                                 throws IOException
        Un-tars one single file with the given file name from a tar.gz file.
        Throws:
        IOException