com.metamatrix.core.util
Class ZipFileUtil

java.lang.Object
  extended by com.metamatrix.core.util.ZipFileUtil

public final class ZipFileUtil
extends java.lang.Object

This class provides utilities to manipulate Zip files.


Method Summary
static boolean add(java.io.File zipFile, java.lang.String fileName)
          Adds the file with the specified name to the specified zip file.
static boolean add(java.lang.String zipFileName, java.lang.String fileName)
          Adds the file with the specified name to the zip file with the specified name.
static boolean add(java.lang.String zipFileName, java.lang.String entryName, java.lang.String fileName)
          Adds the file with the specified name to the zip file with the specified name.
static boolean addAll(java.io.File zipFile, java.lang.String dirName)
          Adds all of the files in the specified directory to the specified zip file.
static boolean addAll(java.io.File zipFile, java.lang.String dirName, java.lang.String pathInZip)
          Adds all of the files in the specified directory to the specified zip file.
static void extract(java.lang.String zipFileName, java.lang.String destinationDirectory)
          Extract the given zip file to the given destination directory base.
static java.util.List<java.lang.String> find(java.io.File zipFile, java.lang.String regexExpression, boolean ignoreCase)
          Will find all entries in the jar based on the expression specified and based on if case is ignored.
static java.io.InputStream get(java.io.File zipFile, java.lang.String fileName, boolean ignoreCase)
          Returns the file with the specified name to the specified zip file.
static java.util.jar.Manifest getManifest(java.io.File jarfile)
          Attempts to obtain the manifest file from the specified file, which must be either a .jar or .zip file.
static boolean remove(java.io.File zipFile, java.lang.String fileName)
          Removes the file with the specified name to the specified zip file.
static boolean remove(java.io.File zipFile, java.lang.String fileName, boolean ignoreCase)
          Removes the file with the specified name to the specified zip file.
static boolean remove(java.lang.String zipFileName, java.lang.String fileName)
          Removes the file with the specified name from the zip file with the specified name.
static boolean remove(java.lang.String zipFileName, java.lang.String fileName, boolean ignoreCase)
          Removes the file with the specified name from the zip file with the specified name.
static boolean replace(java.io.File zipFile, java.lang.String replaceName, java.io.InputStream replaceStream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

add

public static boolean add(java.lang.String zipFileName,
                          java.lang.String fileName)
                   throws java.io.IOException
Adds the file with the specified name to the zip file with the specified name.

Parameters:
zipFileName - The name of the zip file to which the file with the specified name will be added.
fileName - The name of the file to be added.
Returns:
True if the file with the specified name was successfully added to the zip file with the specified name.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

add

public static boolean add(java.lang.String zipFileName,
                          java.lang.String entryName,
                          java.lang.String fileName)
                   throws java.io.IOException
Adds the file with the specified name to the zip file with the specified name.

Parameters:
zipFileName - The name of the zip file to which the file with the specified name will be added.
entryName - The name to call the entry in the zip file.
fileName - The name of the file to be added.
Returns:
True if the file with the specified name was successfully added to the zip file with the specified name.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

add

public static boolean add(java.io.File zipFile,
                          java.lang.String fileName)
                   throws java.io.IOException
Adds the file with the specified name to the specified zip file.

Parameters:
zipFile - The zip file to which the file with the specified name will be added.
fileName - The name of the file to be added.
Returns:
True if the file with the specified name was successfully added to the specified zip file.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

addAll

public static boolean addAll(java.io.File zipFile,
                             java.lang.String dirName)
                      throws java.io.IOException
Adds all of the files in the specified directory to the specified zip file.

Parameters:
zipFile - The zip file to which the file with the specified name will be added.
dirName - The name of the directory which contains the files to be added.
Returns:
True if the files wes successfully added to the specified zip file.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

addAll

public static boolean addAll(java.io.File zipFile,
                             java.lang.String dirName,
                             java.lang.String pathInZip)
                      throws java.io.IOException
Adds all of the files in the specified directory to the specified zip file.

Parameters:
zipFile - The zip file to which the file with the specified name will be added.
dirName - The name of the directory which contains the files to be added.
pathInZip - Path in which the files should be added in the zip.
Returns:
True if the files wes successfully added to the specified zip file.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

extract

public static void extract(java.lang.String zipFileName,
                           java.lang.String destinationDirectory)
                    throws java.io.IOException
Extract the given zip file to the given destination directory base.

Parameters:
zipFileName - The full path and file name of the Zip file to extract.
destinationDirectory - The root directory to extract to.
Throws:
java.io.IOException

remove

public static boolean remove(java.lang.String zipFileName,
                             java.lang.String fileName,
                             boolean ignoreCase)
                      throws java.io.IOException
Removes the file with the specified name from the zip file with the specified name.

Parameters:
zipFileName - The name of the zip file from which the file with the specified name will be removed.
fileName - The name of the file to be removed.
ignoreCase - Indicates whether the case of the filename should be ignored when finding the match.
Returns:
True if the file with the specified name was successfully removed from the zip file with the specified name.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

remove

public static boolean remove(java.lang.String zipFileName,
                             java.lang.String fileName)
                      throws java.io.IOException
Removes the file with the specified name from the zip file with the specified name.

Parameters:
zipFileName - The name of the zip file from which the file with the specified name will be removed.
fileName - The name of the file to be removed.
Returns:
True if the file with the specified name was successfully removed from the zip file with the specified name.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

remove

public static boolean remove(java.io.File zipFile,
                             java.lang.String fileName)
                      throws java.io.IOException
Removes the file with the specified name to the specified zip file.

Parameters:
zipFile - The zip file from which the file with the specified name will be removed.
fileName - The name of the file to be removed.
Returns:
True if the file with the specified name was successfully removed from the specified zip file.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

remove

public static boolean remove(java.io.File zipFile,
                             java.lang.String fileName,
                             boolean ignoreCase)
                      throws java.io.IOException
Removes the file with the specified name to the specified zip file.

Parameters:
zipFile - The zip file from which the file with the specified name will be removed.
fileName - The name of the file to be removed.
ignoreCase - Indicates whether the case of the filename should be ignored when finding the match.
Returns:
True if the file with the specified name was successfully removed from the specified zip file.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

replace

public static boolean replace(java.io.File zipFile,
                              java.lang.String replaceName,
                              java.io.InputStream replaceStream)
                       throws java.io.IOException
Throws:
java.io.IOException

get

public static java.io.InputStream get(java.io.File zipFile,
                                      java.lang.String fileName,
                                      boolean ignoreCase)
                               throws java.io.IOException
Returns the file with the specified name to the specified zip file.

Parameters:
zipFile - The zip file from which the file with the specified name will be retrieved from.
fileName - The name of the file to be returned.
ignoreCase - Indicates whether the case of the filename should be ignored when finding the match.
Returns:
True if the file with the specified name was successfully removed from the specified zip file.
Throws:
java.io.IOException - If an I/O error occurs updating the zip file.
Since:
4.3

find

public static java.util.List<java.lang.String> find(java.io.File zipFile,
                                                    java.lang.String regexExpression,
                                                    boolean ignoreCase)
                                             throws java.io.IOException
Will find all entries in the jar based on the expression specified and based on if case is ignored.

Parameters:
zipFile - The zip file from which the find will be performed.
regexExpression - The regex expression supported by java.util.regex
ignoreCase - Indicates whether the case of an entry in the jar file should be ignored when finding the match.
Returns:
List of entry names that were found to match the regex expression
Throws:
java.io.IOException - If an I/O error occurs reading the zip file.
Since:
6.0

getManifest

public static java.util.jar.Manifest getManifest(java.io.File jarfile)
Attempts to obtain the manifest file from the specified file, which must be either a .jar or .zip file.

Parameters:
path -
VENDOR -
Returns:
Manifest, if one exist, other returns null


Copyright © 2009. All Rights Reserved.