public class UtilZip extends Object
Prefer these to the other UtilTar methods. Here is the typical example:
// compress a directory called "resources" accessible from some
// source path.
UtilZip.getZipArchive(
sourceFolderPath.resolve("resources"),
destFolderPath.resolve("resources.zip"));
// Unzip somewhere else
UtilZip.unzip(
destFolderPath.resolve("resources.zip")
somewherePath.resolve("resources"),
);
| Modifier and Type | Class and Description |
|---|---|
static interface |
UtilZip.Visitor
Use this interface to walk the file being archived.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
unzip(byte[] sourceArchiveContent,
Path destination)
Unzip a zip archive byte array to some destination folder.
|
static void |
unzip(Path sourceArchivePath,
Path destination)
Unzip a zip archive to some destination folder.
|
static void |
zip(Path sourceFolderPath,
Path destinationFolderPath)
zip a folder.
|
static void |
zip(Path sourceFolderPath,
Path destinationFolderPath,
UtilZip.Visitor visitor) |
public static void zip(Path sourceFolderPath, Path destinationFolderPath) throws IOException
sourceFolderPath - the source folderdestinationFolderPath - the destination folderIOExceptionpublic static void zip(Path sourceFolderPath, Path destinationFolderPath, UtilZip.Visitor visitor) throws IOException
IOExceptionpublic static void unzip(Path sourceArchivePath, Path destination) throws IOException
sourceArchivePath - the path to the source archive filedestination - the path where to store the extracted content.IOException, - in particular if the destination folder is a regular file.IOExceptionpublic static void unzip(byte[] sourceArchiveContent,
Path destination)
throws IOException
sourceArchiveContent - the archive byte arraydestination - the destination folder. It will be created if not exiting.IOException, - in particular if the destination folder is a regular file.IOExceptionCopyright © 2014–2022. All rights reserved.