public class ArchiveUtils extends Object
| Modifier | Constructor and Description |
|---|---|
protected |
ArchiveUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
tarGzExtractSingleFile(File tarGz,
File destination,
String pathInTarGz)
Extract a single file from a tar.gz file.
|
static List<String> |
tarGzListFiles(File tarGzFile)
List all of the files and directories in the specified tar.gz file
|
protected static List<String> |
tarGzListFiles(File file,
boolean isTarGz) |
static List<String> |
tarListFiles(File tarFile)
List all of the files and directories in the specified tar.gz file
|
static void |
unzipFileTo(String file,
String dest)
Extracts all files from the archive to the specified destination.
Note: Logs the path of all extracted files by default. |
static void |
unzipFileTo(String file,
String dest,
boolean logFiles)
Extracts all files from the archive to the specified destination, optionally logging the extracted file path.
Can handle .zip, .jar, .tar.gz, .tgz, .tar, and .gz formats. |
static void |
zipExtractSingleFile(File zipFile,
File destination,
String pathInZip)
Extract a single file from a .zip file.
|
static List<String> |
zipListFiles(File zipFile)
List all of the files and directories in the specified .zip file
|
public static void unzipFileTo(String file, String dest) throws IOException
unzipFileTo(String, String, boolean) if
logging is not desired.file - the file to extract the files fromdest - the destination directory. Will be created if it does not existIOException - If an error occurs accessing the files or extractingpublic static void unzipFileTo(String file, String dest, boolean logFiles) throws IOException
file - the file to extract the files fromdest - the destination directory. Will be created if it does not existlogFiles - If true: log the path of every extracted file; if false do not logIOException - If an error occurs accessing the files or extractingpublic static List<String> tarListFiles(File tarFile) throws IOException
tarFile - A .tar fileIOExceptionpublic static List<String> tarGzListFiles(File tarGzFile) throws IOException
tarGzFile - A tar.gz fileIOExceptionprotected static List<String> tarGzListFiles(File file, boolean isTarGz) throws IOException
IOExceptionpublic static List<String> zipListFiles(File zipFile) throws IOException
zipFile - Zip fileIOExceptionpublic static void zipExtractSingleFile(File zipFile, File destination, String pathInZip) throws IOException
zipFile - Zip file to extract fromdestination - Destination filepathInZip - Path in the zip to extractIOException - If exception occurs while reading/writingpublic static void tarGzExtractSingleFile(File tarGz, File destination, String pathInTarGz) throws IOException
unzipFileTo(String, String) for batch extraction insteadtarGz - A tar.gz filedestination - The destination file to extract topathInTarGz - The path in the tar.gz file to extractIOExceptionCopyright © 2022. All rights reserved.