com.mizar.util
Class ZipTools

java.lang.Object
  extended by com.mizar.util.ZipTools

public class ZipTools
extends java.lang.Object


Constructor Summary
ZipTools()
           
 
Method Summary
static void compressFiles(java.lang.String outfile, java.lang.String[] fileslist)
          Compresses and archives files using lossless compression.
static int compressFiles(java.util.zip.ZipOutputStream out, java.lang.String baseFolder, java.lang.String relativeFolder)
           
static int compressFolder(java.lang.String outFilename, java.lang.String baseFolder, java.lang.String relativeFolder, boolean removeFolder)
           
static boolean confirmFilePath(java.lang.String absolutePathedFile)
          Useful to ensure that the folder associated with a file exists.
static boolean confirmFolder(java.lang.String folder)
          Useful to create folders
static int decompress(java.io.InputStream zipFile, java.lang.String targetFolder)
           
static int decompress(java.io.InputStream zipFile, java.lang.String targetFolder, boolean caseFlag)
          Almost exact the same methos as decompress, but enforce the case sensitive output
static int decompress(java.io.InputStream zipFile, java.lang.String targetFolder, int changeCase)
           
static int decompress(java.lang.String zipFile, java.lang.String targetFolder)
           
static int decompress(java.lang.String zipFile, java.lang.String targetFolder, int changeCase)
           
static java.lang.String[] list(java.lang.String zipFile)
           
static boolean possibleZipFile(java.lang.String fileName)
          The method returns true if the file type is .zip.gz.7z.jar.ear.war
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipTools

public ZipTools()
Method Detail

possibleZipFile

public static boolean possibleZipFile(java.lang.String fileName)
The method returns true if the file type is

Parameters:
fileName -
Returns:
true if the file extension looks like a zip file

compressFiles

public static int compressFiles(java.util.zip.ZipOutputStream out,
                                java.lang.String baseFolder,
                                java.lang.String relativeFolder)

compressFiles

public static void compressFiles(java.lang.String outfile,
                                 java.lang.String[] fileslist)
                          throws java.lang.Exception
Compresses and archives files using lossless compression. The output of the process is a .zip file as defined by the @param outfile.

Parameters:
outfile - Name of the file created by the ZIP process.
fileslist - is the list of files to add to the archive
Throws:
java.lang.Exception

compressFolder

public static int compressFolder(java.lang.String outFilename,
                                 java.lang.String baseFolder,
                                 java.lang.String relativeFolder,
                                 boolean removeFolder)
Parameters:
outFilename - the fully specified name of the zip file to create including absolute path and extention.
baseFolder - the base folder in which to find folder
relativeFolder - the relative folder that will be encoded in the zip file
Returns:
the number of files zipped

decompress

public static int decompress(java.io.InputStream zipFile,
                             java.lang.String targetFolder)
                      throws java.io.IOException
Parameters:
zipFile - the absolute path of the zip file to decompress
targetFolder - the target folder under which the files are decompressed. This folder does not have to preexist.
Returns:
Throws:
java.io.IOException

decompress

public static int decompress(java.io.InputStream zipFile,
                             java.lang.String targetFolder,
                             int changeCase)
                      throws java.io.IOException
Parameters:
zipFile - the absolute path of the zip file to decompress
targetFolder - the target folder under which the files are decompressed. This folder does not have to preexist.
changeCase - -1=toLower, 1=toUpper, default=no change
Returns:
Throws:
java.io.IOException

decompress

public static int decompress(java.io.InputStream zipFile,
                             java.lang.String targetFolder,
                             boolean caseFlag)
                      throws java.io.IOException
Almost exact the same methos as decompress, but enforce the case sensitive output

Parameters:
zipFile -
targetFolder -
caseFlag - if true, it write all Upper case file name, if false, it write all Lower case
Returns:
Throws:
java.io.IOException

decompress

public static int decompress(java.lang.String zipFile,
                             java.lang.String targetFolder)
                      throws java.io.IOException
Parameters:
zipFile - the absolute path of the zip file to decompress
targetFolder - the target folder under which the files are decompressed. This folder does not have to preexist.
Returns:
the number of files decompressed
Throws:
java.io.IOException

decompress

public static int decompress(java.lang.String zipFile,
                             java.lang.String targetFolder,
                             int changeCase)
                      throws java.io.IOException
Parameters:
zipFile - the absolute path of the zip file to decompress
targetFolder - the target folder under which the files are decompressed. This folder does not have to preexist.
changeCase - -1=toLower, 1=toUpper, default=no change
Returns:
the number of files decompressed
Throws:
java.io.IOException

list

public static java.lang.String[] list(java.lang.String zipFile)
Parameters:
zipFile - absolute path of the zip file to wkt
Returns:
an array of file names (with paths) found in the zip file

confirmFilePath

public static boolean confirmFilePath(java.lang.String absolutePathedFile)
Useful to ensure that the folder associated with a file exists.

Parameters:
absolutePathedFile - A fully specified file name
Returns:
true if the parent folder of absolutePathedFile exists or was successfully created

confirmFolder

public static boolean confirmFolder(java.lang.String folder)
Useful to create folders

Parameters:
folder - the name of a folder
Returns:
true if the folder exists or was successfully created. false if a non-directory file of the same name exists.