public abstract class ZipUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ZipUtil.ZipEntryVisitor
Used by
walkZipFile(File, ZipEntryVisitor) to visit zip entries. |
| Modifier and Type | Method and Description |
|---|---|
static void |
unzipFile(File zipFile,
File destDir)
Unzips the content of the given zip file to the specified directory.
|
static void |
unzipFile(InputStream zipContent,
File outputDir)
Writes the zip content out to the specified directory.
|
static void |
walkZip(InputStream zipFileStream,
ZipUtil.ZipEntryVisitor visitor,
boolean readFully)
Walks the provided zip file stream.
|
static void |
walkZipFile(File zipFile,
ZipUtil.ZipEntryVisitor visitor)
Walks the entries of a zip file, allowing a listener to "visit" each node and perform tasks on
the zip entry.
|
static void |
zipFileOrDirectory(File fileOrDirToZip,
File zipFile)
Zips up the given file or directory and stores the zip file at
zipFile. |
static void |
zipFileOrDirectory(File fileOrDirToZip,
ZipOutputStream zos) |
public static void zipFileOrDirectory(File fileOrDirToZip, File zipFile) throws IOException
zipFile.
Note that zipping up a directory and if the output zip file is to be located in or under
the directory being zipped, an exception will be thrown - you must output the zip file
in another location outside of the directory being zipped.fileOrDirToZip - what to zip upzipFile - where to store the zip fileIOExceptionpublic static void zipFileOrDirectory(File fileOrDirToZip, ZipOutputStream zos) throws IOException
IOExceptionpublic static void unzipFile(File zipFile, File destDir) throws IOException
zipFile - the zip file to unzipdestDir - root directory where the zip files will be extractedIOException - if any errors occur during the reading or writingpublic static void unzipFile(InputStream zipContent, File outputDir) throws IOException
zipContent - stream containing the content to write; should be formatted as a ZIP fileoutputDir - root directory where the zip files will be extractedIOException - if any errors occur during the reading or writingpublic static void walkZipFile(File zipFile, ZipUtil.ZipEntryVisitor visitor) throws Exception
zipFile - the zip file to walkvisitor - the object that will be notified for each entry in the zip fileException - if any errors occur during the reading or visitingpublic static void walkZip(InputStream zipFileStream, ZipUtil.ZipEntryVisitor visitor, boolean readFully) throws Exception
zipFileStream - the stream of zip file contentsvisitor - the visitor to call on each zip entryreadFully - true if the whole zip file should be read from the stream even if visitor bailed out, false to
quit reading as soon as the visitor bails out.ExceptionCopyright © 2008-2014 Red Hat, Inc.. All Rights Reserved.