Package org.hortonmachine.gears.utils
Class CompressionUtilities
- java.lang.Object
-
- org.hortonmachine.gears.utils.CompressionUtilities
-
public class CompressionUtilities extends Object
Utilities class to zip and unzip folders.- Since:
- 0.7.0
- Author:
- Andrea Antonello (www.hydrologis.com)
-
-
Constructor Summary
Constructors Constructor Description CompressionUtilities()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringunzipFolder(String zipFile, String destFolder, boolean addTimeStamp)Uncompress a compressed file to the contained structure.static FileunzipSingleFile(String zipFile, String destFolder, boolean addTimeStamp)static voidzipFiles(File[] srcFiles, String destZipFile)Compress a set of files and its contents if folders.static voidzipFolder(String srcFolder, String destZipFile, boolean addBaseFolder)Compress a folder and its contents.
-
-
-
Method Detail
-
zipFolder
public static void zipFolder(String srcFolder, String destZipFile, boolean addBaseFolder) throws IOException
Compress a folder and its contents.- Parameters:
srcFolder- path to the folder to be compressed.destZipFile- path to the final output zip file.addBaseFolder- flag to decide whether to add also the provided base (srcFolder) folder or not.- Throws:
IOException
-
zipFiles
public static void zipFiles(File[] srcFiles, String destZipFile) throws IOException
Compress a set of files and its contents if folders.- Parameters:
srcFiles- the files to compress.destZipFile- path to the final output zip file.- Throws:
IOException
-
unzipFolder
public static String unzipFolder(String zipFile, String destFolder, boolean addTimeStamp) throws IOException
Uncompress a compressed file to the contained structure.- Parameters:
zipFile- the zip file that needs to be unzippeddestFolder- the folder into which unzip the zip file and create the folder structureaddTimeStamp- iftrue, the timestamp is added if the base folder already exists.- Returns:
- the name of the internal base folder or
null. - Throws:
IOException
-
unzipSingleFile
public static File unzipSingleFile(String zipFile, String destFolder, boolean addTimeStamp) throws IOException
- Throws:
IOException
-
-