|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.util.ZipUtil
public class ZipUtil
Opérations sur des fichiers Zip. Compression et décompression avec ou sans filtres, scan des fichiers créés ou écrasés lors de la décompression...
Created: 24 août 2006 10:13:35
| Field Summary | |
|---|---|
protected static FileFilter |
ALL_FILE_FILTER
Accept all file pattern. |
| Constructor Summary | |
|---|---|
ZipUtil()
|
|
| Method Summary | |
|---|---|
static void |
compress(File zipFile,
File fileOrDirectory)
If fileOrDirectory is directory Compress recursively all file in this directory, else if is just file compress one file. |
static void |
compress(File zipFile,
File fileOrDirectory,
FileFilter filter)
If fileOrDirectory is directory Compress recursively all file in this directory, else if is just file compress one file. |
static void |
compress(File zipFile,
File fileOrDirectory,
FileFilter filter,
boolean createMD5)
If fileOrDirectory is directory Compress recursively all file in this directory, else if is just file compress one file. |
static void |
compressFiles(File zipFile,
File root,
Collection<File> includes)
Compress 'includes' files in zipFile. |
static void |
compressFiles(File zipFile,
File root,
Collection<File> includes,
boolean createMD5)
Compress 'includes' files in zipFile. |
protected static String |
convertToLocalEntryName(String txt)
|
static boolean |
isZipFile(File file)
Tests if the given file is a zip file. |
static void |
scan(File zipFile,
File targetDir,
List<String> newFiles,
List<String> existingFiles,
FileFilter excludeFilter,
String renameFrom,
String renameTo)
Scan a zipFile, and fill two lists of relative paths corresponding of zip entries. |
static List<String>[] |
scanAndExplodeZip(File source,
File root,
FileFilter excludeFilter)
|
static String |
uncompress(File file,
File targetDir)
Uncompress zipped file in targetDir. |
static String |
uncompress(File file,
File targetDir,
List<String> toTreate,
String renameFrom,
String renameTo)
uncompress zipped file in targetDir. |
static String |
uncompressAndRename(File file,
File targetDir,
String renameFrom,
String renameTo)
Uncompress zipped file in targetDir, and rename uncompressed file if necessary. |
static void |
uncompressFiltred(File file,
File targetDir,
String... excludes)
Unzip compressed archive and keep non excluded patterns. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static FileFilter ALL_FILE_FILTER
| Constructor Detail |
|---|
public ZipUtil()
| Method Detail |
|---|
public static String uncompress(File file,
File targetDir)
throws IOException
file - the zip source filetargetDir - the destination directory
IOException - if any problem while uncompressing
public static String uncompressAndRename(File file,
File targetDir,
String renameFrom,
String renameTo)
throws IOException
file - the zip source filetargetDir - the destination directoryrenameFrom - pattern to permit rename file before uncompress itrenameTo - new name for file if renameFrom is applicable to it
you can use $1, $2, ... if you have '(' ')' in renameFrom
IOException - if any problem while uncompressing
public static void compressFiles(File zipFile,
File root,
Collection<File> includes)
throws IOException
zipFile - the destination zip fileroot - for all file in includes that is in this directory, then we
remove this directory in zip entry name (aka -C for tar), can be null;includes - the files to include in zip
IOException - if any problem while compressing
public static void compressFiles(File zipFile,
File root,
Collection<File> includes,
boolean createMD5)
throws IOException
zipFile - the destination zip fileroot - for all file in includes that is in this directory, then we
remove this directory in zip entry name (aka -C for tar), can be null;includes - the files to include in zipcreateMD5 - also create a MD5 file (zip name + .md5). MD5 file is created after zip.
IOException - if any problem while compressing
public static void compress(File zipFile,
File fileOrDirectory)
throws IOException
zipFile - the target zip filefileOrDirectory - the file or directory to compress
IOException - if any problem while compressing
public static void compress(File zipFile,
File fileOrDirectory,
FileFilter filter)
throws IOException
zipFile - the target zip filefileOrDirectory - the file or directory to compressfilter - used to accept file, if null, all file is accepted
IOException - if any problem while compressing
public static void compress(File zipFile,
File fileOrDirectory,
FileFilter filter,
boolean createMD5)
throws IOException
zipFile - the target zip filefileOrDirectory - the file or directory to compressfilter - used to accept file, if null, all file is acceptedcreateMD5 - also create a MD5 file (zip name + .md5). MD5 file is created after zip.
IOException - if any problem while compressing
public static void scan(File zipFile,
File targetDir,
List<String> newFiles,
List<String> existingFiles,
FileFilter excludeFilter,
String renameFrom,
String renameTo)
throws IOException
targetDir.
targetDir is null we don't fill
list.
zipFile - location of the zip to scanZiptargetDir - location of destination for a uncompress operation.
If null we don't test to
find overwritten files.newFiles - list of files to be added while a uncompressexistingFiles - list of files to be overwritten while a uncompress
if the targetDir,
(only use if targetDir is not
null)excludeFilter - used to exclude some filesrenameFrom - uncompressAndRename(File, File, String, String)renameTo - uncompressAndRename(File, File, String, String)
IOException - if any exception while dealing with zipfile
public static List<String>[] scanAndExplodeZip(File source,
File root,
FileFilter excludeFilter)
throws IOException
IOException
public static String uncompress(File file,
File targetDir,
List<String> toTreate,
String renameFrom,
String renameTo)
throws IOException
toTreate if not null nor empty, we use it to filter
entries to uncompress : it contains a list of relative local path of
files to uncompress.
Otherwise just delegate to uncompress(File, File).
file - location of zip filetargetDir - destination directorytoTreate - list of relative local path of entries to treaterenameFrom - uncompressAndRename(File, File, String, String)renameTo - uncompressAndRename(File, File, String, String)
IOException - if nay exception while operation
public static void uncompressFiltred(File file,
File targetDir,
String... excludes)
throws IOException
file - archive filetargetDir - destination fileexcludes - excludes pattern (pattern must match complete entry name including root folder)
IOException
public static boolean isZipFile(File file)
throws IOException
file - the file to test
true if the file is a valid zip file,
false otherwise.
IOException - if could not open zip fileprotected static String convertToLocalEntryName(String txt)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||