public final class Zip extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Zip.Archive
This class allows a fine-grained control on the files to be added to
the zip archive.
|
Modifier and Type | Method and Description |
---|---|
static long |
computeCRC(File file)
Utility: computes and returns the CRC-32 of specified file.
|
static void |
unzip(File srcFile,
File dstDir)
Extracts files contained in specified stream to specified directory.
|
static void |
unzip(ZipInputStream zip,
File dstDir)
Extracts file contained in specified stream to specified directory.
|
static void |
zip(File srcDir,
boolean includingTopDir,
FilenameFilter filter,
File dstFile)
Creates a zip archive containing the content of specified directory.
|
public static void zip(File srcDir, boolean includingTopDir, FilenameFilter filter, File dstFile) throws IOException
srcDir
- directory containing the files to be zipped. This
directory is traversed recursively.includingTopDir
- if true
, the basename of the top
directory also appears in the created zip archive. Example: if
C:\foo\bar is to be zipped and this option is
true
, all the paths contained in the zip archive will
start with "bar/".filter
- may be used to filter the files to be zipped. May be
null
, in which case, all the files and directory contained
in srcDir are to be zipped.dstFile
- zip archive to be createdIOException
- if there is an I/O problem during the creation
of the zip archivepublic static final long computeCRC(File file) throws IOException
IOException
public static void unzip(File srcFile, File dstDir) throws IOException
Closes input stream when done.
srcFile
- source Zip file from which to extract filesdstDir
- directory where files are to be extractedIOException
- if an I/O problem occurs during the extraction
of filespublic static void unzip(ZipInputStream zip, File dstDir) throws IOException
Does not close zip input stream when done.
zip
- zip stream or jar stream from which to extract filesdstDir
- directory where files are to be extractedIOException
- if an I/O problem occurs during the extraction
of files