public class ZipUtil extends Object
| Constructor and Description |
|---|
ZipUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
safeUnzip(Path zipFile,
Path unzipDirectory)
Convenience method.
|
static void |
safeUnzip(ZipInputStream zis,
Path unzipDirectory)
Extract a ZipInputStream to the target destination directory.
|
static void |
zipDirectory(String sourceDir,
String zipExtension)
Compresses a given directory.
|
static void |
zipDirectory(String sourceDir,
String zipExtension,
String destinationPathWithoutExtension)
Compresses a given directory.
|
static void |
zipFiles(String zipPath,
String sourceDir,
String... filenames)
Creates a ZIP file and adds a list of files in it.
|
public static void safeUnzip(ZipInputStream zis, Path unzipDirectory) throws IOException
zis - unzipDirectory - IOExceptionpublic static void safeUnzip(Path zipFile, Path unzipDirectory) throws IOException
zipFile - unzipDirectory - IOExceptionpublic static void zipDirectory(String sourceDir, String zipExtension)
This method uses the Java ZIP package and does not supports files to zip that have a path with extended characters.
sourceDir - the given directory to be compressedzipExtension - an extension for the output ZIP file (default is .zip if a
null or empty string is passed by the caller). The extension
is expected to contain the leading period.public static void zipDirectory(String sourceDir, String zipExtension, String destinationPathWithoutExtension)
This method uses the Java ZIP package and does not supports files to zip that have a path with extended characters.
sourceDir - the given directory to be compressedzipExtension - an extension for the output ZIP file (default is .zip if a
null or empty string is passed by the caller). The extension
is expected to contain the leading period.destinationPathWithoutExtension - output path of the zip file, without extension. Use null to
use the source directory path.public static void zipFiles(String zipPath, String sourceDir, String... filenames)
zipPath - the path of the ZIP file to create.sourceDir - the path of the directory where the source files are located.filenames - the list of files to zip.Copyright © 2021. All rights reserved.