CompressionUtil

CompressionUtil provides utility methods for compressing and decompressing files in various formats such as TAR.GZ and ZIP. It offers functionalities to compress multiple files into a single archive and to decompress archives into specified directories.

Methods

compressTarGzipFile(File: inputFile, String: outputFileName): File

Compresses file into a single TAR.GZ file.

@paraminputFiles — - A file path to be compressed.

@paramoutputFileName — - The name of the output TAR.GZ file.

@returns — The File with the compressed ZIP file.

// Read a file
var filePath = "path/to/your/file.txt";
var file = FileUtil.readFile(filePath);
CompressionUtil.compressTarGzipFiles(file, "generatedTarGZFileName");

compressTarGzipFiles(File[]: inputFiles, String: outputFileName): File

Compresses multiple files into a single TAR.GZ file.

@paraminputFiles — - An array of file paths to be compressed.

@paramoutputFileName — - The name of the output TAR.GZ file.

@returns — The File with the compressed ZIP file.

// Read a file
var filePath = "path/to/your/file.txt";
var file = FileUtil.readFile(filePath);
CompressionUtil.compressTarGzipFiles([file], "generatedTarGZFileName");

compressZipFile(File: inputFile, String: outputFileName): File

Compresses file into a single ZIP file.

@paraminputFile — - A file path to be compressed.

@paramoutputFileName — - The name of the output ZIP file.

@returns — The File with the compressed ZIP file.

// Read a file
var filePath = "path/to/your/file.txt";
var file = FileUtil.readFile(filePath);
CompressionUtil.compressZipFiles(file, "generatedZipFileName");

compressZipFiles(File[]: inputFiles, String: outputFileName): File

Compresses multiple files into a single ZIP file.

@paraminputFiles — - An array of file paths to be compressed.

@paramoutputFileName — - The name of the output ZIP file.

@returns — The File with the compressed ZIP file.

// Read a file
var filePath = "path/to/your/file.txt";
var file = FileUtil.readFile(filePath);
CompressionUtil.compressZipFiles([file], "generatedZipFileName");

decompressTarGzipFile(File: inputFiles, String: outputDirName): File

Decompresses a TAR.GZ file into a specified directory.

@paraminputFile — - The path of the TAR.GZ file to be decompressed.

@paramoutputDirName — - The name of the output directory.

@returns — A File path of the output directory.

// Read a file
var filePath = "path/to/your/file.tar.gz";
var file = FileUtil.readFile(filePath);
CompressionUtil.decompressTarGzipFile(file, "uncompressedTarGZDirName");

decompressZipFile(File: inputFiles, String: outputDirName): File

Decompresses a ZIP file into a specified directory.

@paraminputFile — - The path of the ZIP file to be decompressed.

@paramoutputDirName — - The name of the output directory.

@returns — A File path of the output directory.

// Read a file
var filePath = "path/to/your/file.zip";
var file = FileUtil.readFile(filePath);
CompressionUtil.decompressZipFile(file, "uncompressedZipDirName");