public class CompressionUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
CompressionUtil.UnsupportedCompressionType |
| Modifier and Type | Method and Description |
|---|---|
static File |
decompressFile(File compressedFile)
Tries to decompress a file into a newly created temporary directory, trying gzip or zip regardless of the filename
or its suffix.
|
static List<File> |
decompressFile(File directory,
File compressedFile)
Defaults keeping subDirectories to false.
|
static List<File> |
decompressFile(File directory,
File compressedFile,
boolean keepSubdirectories)
Tries to decompress a file using TAR+gzip, TAR or Zip regardless of the filename or its suffix.
|
static List<File> |
ungzipFile(File directory,
File gzipFile,
boolean isTarred)
Gunzip a file.
|
static List<File> |
untarFile(File directory,
File tarFile)
Extracts a plain TAR file.
|
static List<File> |
untgzFile(File directory,
File tgzFile)
Extracts a gzipped TAR file.
|
static List<File> |
unzipFile(File directory,
File zipFile)
Defaults keepSubdirectories to false.
|
static List<File> |
unzipFile(File directory,
File zipFile,
boolean keepSubdirectories)
Extracts a zipped file into a target directory.
|
static void |
zipDir(File dir,
File zipFile)
Zip a directory with all files but skipping included subdirectories.
|
static void |
zipDir(File dir,
File zipFile,
boolean inclSubdirs)
Zip a directory with all files.
|
static void |
zipFile(File file,
File zipFile) |
static void |
zipFiles(Collection<File> files,
File rootContext,
File zipFile)
Creates a zip archive from a given collection of files.
|
public static File decompressFile(File compressedFile) throws IOException, CompressionUtil.UnsupportedCompressionType
IOExceptionCompressionUtil.UnsupportedCompressionTypepublic static List<File> decompressFile(File directory, File compressedFile) throws IOException, CompressionUtil.UnsupportedCompressionType
public static List<File> decompressFile(File directory, File compressedFile, boolean keepSubdirectories) throws IOException, CompressionUtil.UnsupportedCompressionType
directory - directory where archive's contents will be decompressed tocompressedFile - compressed fileIOException - if problem occurred reading compressed file, or directory couldn't be written
toCompressionUtil.UnsupportedCompressionType - if the compression type wasn't recognizedpublic static List<File> untgzFile(File directory, File tgzFile) throws IOException
directory - where the file should be extracted totgzFile - to extractIOExceptionpublic static List<File> untarFile(File directory, File tarFile) throws IOException
directory - where the file should be extracted totarFile - to extractIOExceptionpublic static List<File> ungzipFile(File directory, File gzipFile, boolean isTarred) throws IOException
directory - the output directory for the uncompressed file(s)gzipFile - the gzip fileisTarred - true if the gzip contains a TARIOException - if reading or writing failspublic static List<File> unzipFile(File directory, File zipFile) throws IOException
IOExceptionunzipFile(java.io.File, java.io.File, boolean)public static void zipDir(File dir, File zipFile) throws IOException
dir - the directory to zipzipFile - the zipped fileIOExceptionpublic static void zipDir(File dir, File zipFile, boolean inclSubdirs) throws IOException
dir - the directory to zipzipFile - the zipped fileinclSubdirs - if true includes all subdirectories recursivelyIOExceptionpublic static void zipFile(File file, File zipFile) throws IOException
IOExceptionpublic static void zipFiles(Collection<File> files, File rootContext, File zipFile) throws IOException
files - to be included in the zip archiverootContext - optional path to be removed from each filezipFile - the zip file to be createdIOExceptionpublic static List<File> unzipFile(File directory, File zipFile, boolean keepSubdirectories) throws IOException
directory - where the zipped file and its subdirectories should be extracted tozipFile - to extractkeepSubdirectories - whether to preserve subdirectories or notIOExceptionCopyright © 2024 Global Biodiversity Information Facility (GBIF). All rights reserved.