|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nuiton.wikitty.publication.externalize.JarUtil
public class JarUtil
Opérations sur des fichiers Jar. Compression et décompression avec ou sans filtres, scan des fichiers créés ou écrasés lors de la décompression... Créée à partir de org.nuiton.util.ZipUtil
| Field Summary | |
|---|---|
protected static FileFilter |
ALL_FILE_FILTER
Accept all file pattern. |
static FileFilter |
jarFilter
|
| Constructor Summary | |
|---|---|
JarUtil()
|
|
| Method Summary | |
|---|---|
static void |
compress(File jarFile,
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 jarFile,
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 jarFile,
File fileOrDirectory,
Manifest mf)
If fileOrDirectory is directory Compress recursively all file in this directory, else if is just file compress one file. |
static void |
compress(File jarFile,
File fileOrDirectory,
Manifest mf,
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 jarFile,
File fileOrDirectory)
|
static void |
compressFiles(File jarFile,
File root,
Collection<File> includes)
Compress 'includes' files in jarFile. |
static void |
compressFiles(File jarFile,
File root,
Manifest mf,
Collection<File> includes,
boolean createMD5)
Compress 'includes' files in jarFile. |
protected static String |
convertToLocalEntryName(String txt)
|
static byte[] |
getByteContent(JarFile jar,
JarEntry jarEnt)
|
static String |
getStringContent(JarFile jar,
JarEntry jarEntry)
|
static void |
scan(File jarFile,
File targetDir,
List<String> newFiles,
List<String> existingFiles,
FileFilter excludeFilter,
String renameFrom,
String renameTo)
Scan a jarFile, and fill two lists of relative paths corresponding of jar entries. |
static List<String>[] |
scanAndExplodeJar(File source,
File root,
FileFilter excludeFilter)
|
static String |
uncompress(File file,
File targetDir)
Uncompress jarped file in targetDir. |
static String |
uncompress(File file,
File targetDir,
List<String> toTreate,
String renameFrom,
String renameTo)
uncompress jarped file in targetDir. |
static String |
uncompressAndRename(File file,
File targetDir,
String renameFrom,
String renameTo)
Uncompress jarped file in targetDir, and rename uncompressed file if necessary. |
static void |
uncompressFiltred(File file,
File targetDir,
String... excludes)
Unjar 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 |
|---|
public static FileFilter jarFilter
protected static FileFilter ALL_FILE_FILTER
| Constructor Detail |
|---|
public JarUtil()
| Method Detail |
|---|
public static String uncompress(File file,
File targetDir)
throws IOException
file - the jar 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 jar 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 jarFile,
File fileOrDirectory)
throws IOException
jarFile - fileOrDirectory -
IOException
public static void compressFiles(File jarFile,
File root,
Collection<File> includes)
throws IOException
jarFile - the destination jar fileroot - for all file in includes that is in this directory, then we
remove this directory in jar entry name (aka -C for tar), can
be null;includes - the files to include in jar
IOException - if any problem while compressing
public static void compressFiles(File jarFile,
File root,
Manifest mf,
Collection<File> includes,
boolean createMD5)
throws IOException
jarFile - the destination jar fileroot - for all file in includes that is in this directory, then we
remove this directory in jar entry name (aka -C for tar), can
be null;includes - the files to include in jarcreateMD5 - also create a MD5 file (jar name + .md5). MD5 file is created
after jar.
IOException - if any problem while compressing
public static void compress(File jarFile,
File fileOrDirectory)
throws IOException
jarFile - the target jar filefileOrDirectory - the file or directory to compress
IOException - if any problem while compressing
public static void compress(File jarFile,
File fileOrDirectory,
Manifest mf)
throws IOException
jarFile - the target jar filefileOrDirectory - the file or directory to compressmf - the manifest for the jar
IOException - if any problem while compressing
public static void compress(File jarFile,
File fileOrDirectory,
FileFilter filter)
throws IOException
jarFile - the target jar 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 jarFile,
File fileOrDirectory,
Manifest mf,
FileFilter filter,
boolean createMD5)
throws IOException
jarFile - the target jar filefileOrDirectory - the file or directory to compressfilter - used to accept file, if null, all file is acceptedcreateMD5 - also create a MD5 file (jar name + .md5). MD5 file is created
after jar.
IOException - if any problem while compressing
public static void scan(File jarFile,
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.
jarFile - location of the jar to scanJartargetDir - 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 jarfile
public static List<String>[] scanAndExplodeJar(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 jar 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)
IOExceptionprotected static String convertToLocalEntryName(String txt)
public static String getStringContent(JarFile jar,
JarEntry jarEntry)
throws IOException
IOException
public static byte[] getByteContent(JarFile jar,
JarEntry jarEnt)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||