Modifier and Type | Field and Description |
---|---|
protected static int |
COMP_LEVEL
Compression level of the file.
|
Constructor and Description |
---|
ZipUtils() |
Modifier and Type | Method and Description |
---|---|
protected static void |
createFileWithPath(File f) |
static void |
unzip(ZipFile zipFile,
File dest)
Unzip a zip file into a directory.
|
static void |
zip(String[] directoriesAndFiles,
File dest,
CRC32 crc)
Create a zip file on the given directoriesAndFiles argument and
store the create content in a file denoted by the path in the given dest argument
|
static void |
zipDirectoriesAndFiles(ZipOutputStream zos,
String[] directoriesAndFiles,
CRC32 crc)
Create a zip file that contains all the directory listed in directories parameter.
|
protected static void |
zipDirectory(String directoryName,
int iBaseFolderLength,
ZipOutputStream zos,
CRC32 crc)
Add the given directory into the zipStream.
|
protected static void |
zipFile(String filePath,
int iBaseFolderLength,
ZipOutputStream jos,
CRC32 crc)
Add a file into a zip.
|
protected static void |
zipIt(ZipOutputStream zos,
String[] directoriesAndFiles,
CRC32 crc)
Zip directory content in the given output stream
|
createTempDirectory, deleteRecursively, getExtension, getFileNameWithExtension, removeDir, resolvePropertiesFile
protected static final int COMP_LEVEL
public static void zip(String[] directoriesAndFiles, File dest, CRC32 crc) throws IOException
directoriesAndFiles
- the directories and files to zip (recursively)dest
- the zip destination file that will contains the zipped version of the first argument.crc
- the CRC32 of all zipentries. Can be null if no crc is needed.IOException
- if the zip file cannot be created.public static void zipDirectoriesAndFiles(ZipOutputStream zos, String[] directoriesAndFiles, CRC32 crc) throws IOException
zos
- output stream destinationdirectoriesAndFiles
- the list of directories and files to be zipped.crc
- the CRC32 of all zipentries. Can be null if no crc is needed.IOException
- if an error occurs during the compressionprotected static void zipIt(ZipOutputStream zos, String[] directoriesAndFiles, CRC32 crc) throws IOException
zos
- the output stream in which to store the zipped directorydirectoriesAndFiles
- a list of directories and files to be zippedIOException
- if a zip entry cannot be created.protected static void zipDirectory(String directoryName, int iBaseFolderLength, ZipOutputStream zos, CRC32 crc) throws IOException
directoryName
- the directory to be added in the zip.iBaseFolderLength
- the index in the directoryName from which starts the actual zip entry name.zos
- the stream to write into.crc
- the CRC32 of all zipentries. Can be null if no crc is needed.IOException
- if the zip file cannot be written.protected static void zipFile(String filePath, int iBaseFolderLength, ZipOutputStream jos, CRC32 crc) throws IOException
filePath
- the file to be added in the zip.iBaseFolderLength
- the index in the directoryName from which starts the actual zip entry name.jos
- the stream to write into.crc
- the CRC32 of all zipentries. Can be null if no crc is needed.IOException
- if the zip file cannot be written.public static void unzip(ZipFile zipFile, File dest) throws IOException
zipFile
- The zip file to be unzipped.dest
- the destination directory.IOException
- if the destination does not exist or is not a directory, or if the zip file cannot be extracted.protected static void createFileWithPath(File f) throws IOException
IOException