public class CompressionUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CompressionUtil.Algorithm
Enumeration of all supported compression algorithms by this utility.
|
| Constructor and Description |
|---|
CompressionUtil() |
| Modifier and Type | Method and Description |
|---|---|
static File |
compress(File sourceFile,
File targetDir,
String algorithm,
boolean deleteSourceFileAfterCompressed)
Compresses the source file using a variety of supported compression
algorithms.
|
static File |
compress(File sourceFile,
String algorithm,
boolean deleteSourceFileAfterCompressed)
Compresses the source file using a variety of supported compression
algorithms.
|
static boolean |
isAlgorithmSupported(String algorithm)
Checks if the compression algorithm is supported by this utility class.
|
static boolean |
isFileExtensionSupported(String fileExt)
Checks if the file extension such as "gz" or "zip" is supported by this
utility class.
|
static File |
uncompress(File sourceFile,
boolean deleteSourceFileAfterUncompressed)
Uncompresses the source file using a variety of supported compression
algorithms.
|
static File |
uncompress(File sourceFile,
File targetDir,
boolean deleteSourceFileAfterUncompressed)
Uncompresses the source file using a variety of supported compression
algorithms.
|
public static boolean isAlgorithmSupported(String algorithm)
algorithm - The compression algorithm such as "gzip" or "zip"public static boolean isFileExtensionSupported(String fileExt)
fileExt - The file extension to check such as "gz" or "zip"public static File compress(File sourceFile, String algorithm, boolean deleteSourceFileAfterCompressed) throws FileAlreadyExistsException, IOException
sourceFile - The uncompressed filealgorithm - The compression algorithm to usedeleteSourceFileAfterCompressed - Delete the original source file
only if the compression was successful.FileAlreadyExistsException - Thrown if the target file already
exists and an overwrite is not permitted. This exception is a
subclass of IOException, so its safe to only catch an IOException
if no specific action is required for this case.IOException - Thrown if an error occurs while attempting to
compress the source file.public static File compress(File sourceFile, File targetDir, String algorithm, boolean deleteSourceFileAfterCompressed) throws FileAlreadyExistsException, IOException
sourceFile - The uncompressed filetargetDir - The target directory or null if same directory as sourceFilealgorithm - The compression algorithm to usedeleteSourceFileAfterCompressed - Delete the original source file
only if the compression was successful.FileAlreadyExistsException - Thrown if the target file already
exists and an overwrite is not permitted. This exception is a
subclass of IOException, so its safe to only catch an IOException
if no specific action is required for this case.IOException - Thrown if an error occurs while attempting to
compress the source file.public static File uncompress(File sourceFile, boolean deleteSourceFileAfterUncompressed) throws FileAlreadyExistsException, IOException
sourceFile - The compressed filedeleteSourceFileAfterUncompressed - Delete the original source file
only if the uncompression was successful.FileAlreadyExistsException - Thrown if the target file already
exists and an overwrite is not permitted. This exception is a
subclass of IOException, so its safe to only catch an IOException
if no specific action is required for this case.IOException - Thrown if an error occurs while attempting to
uncompress the source file.public static File uncompress(File sourceFile, File targetDir, boolean deleteSourceFileAfterUncompressed) throws FileAlreadyExistsException, IOException
sourceFile - The compressed filetargetDir - The target directory or null to uncompress in same directory as source filedeleteSourceFileAfterUncompressed - Delete the original source file
only if the uncompression was successful.FileAlreadyExistsException - Thrown if the target file already
exists and an overwrite is not permitted. This exception is a
subclass of IOException, so its safe to only catch an IOException
if no specific action is required for this case.IOException - Thrown if an error occurs while attempting to
uncompress the source file.Copyright © 2012-2015 Cloudhopper by Twitter. All Rights Reserved.