base.util
Class ZipUtil

java.lang.Object
  extended by base.util.ZipUtil

public class ZipUtil
extends java.lang.Object

This class provides some basic methods to compress/uncompress files and folders in zip compression format.

Author:
Guido Angelo Ingenito

Constructor Summary
ZipUtil()
           
 
Method Summary
static void unZipFile(java.io.File inputFile, java.io.File outputDirectory)
          This method provides a simple unzip facility for a composite zip file (a zip file that contains files and folders).
static void zipAllFile(java.io.File[] inputFile, java.io.File outputFile)
           
static void zipAllFile(java.io.File[] inputFile, java.util.zip.ZipOutputStream zipOutputStream)
           
static void zipDirectory(java.io.File inputFile, java.io.File outputFile)
          This method is a wrapper for the method the zipDirectory(File, ZipOutputStream).
static void zipDirectory(java.io.File inputFile, java.util.zip.ZipOutputStream zipOutputStream)
          This method provides a simple zip compression for a file or an entire folder.
static void zipFile(java.io.File inputFile, java.io.File outputFile)
          This method is a wrapper for the method the zipFile(File, ZipOutputStream).
static void zipFile(java.io.File inputFile, java.util.zip.ZipOutputStream zipOutputStream)
          This method provides a simple zip compression for a file (not a folder).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipUtil

public ZipUtil()
Method Detail

zipDirectory

public static void zipDirectory(java.io.File inputFile,
                                java.io.File outputFile)
                         throws java.io.IOException
This method is a wrapper for the method the zipDirectory(File, ZipOutputStream). It provides a more easy interface to be used when must be zipped a file or a folder.

Parameters:
inputFile - The input file/folder to be zipped.
outputFile - The zipped outputted file.
Throws:
java.io.IOException - If something wrong happpens.

zipDirectory

public static void zipDirectory(java.io.File inputFile,
                                java.util.zip.ZipOutputStream zipOutputStream)
                         throws java.io.IOException
This method provides a simple zip compression for a file or an entire folder.

Parameters:
inputFile - The input file/folder whose content must be zipped.
zipOutputStream - The target output stream that points to the location where the zip file must be placed.
Throws:
java.io.IOException - If something wrong happens.

zipAllFile

public static void zipAllFile(java.io.File[] inputFile,
                              java.io.File outputFile)
                       throws java.io.IOException
Throws:
java.io.IOException

zipAllFile

public static void zipAllFile(java.io.File[] inputFile,
                              java.util.zip.ZipOutputStream zipOutputStream)
                       throws java.io.IOException
Throws:
java.io.IOException

zipFile

public static void zipFile(java.io.File inputFile,
                           java.io.File outputFile)
                    throws java.io.IOException
This method is a wrapper for the method the zipFile(File, ZipOutputStream). It provides a more easy interface to be used when must be zipped a file (not a folder).

Parameters:
inputFile - The input file (not a folder) to be zipped.
outputFile - The zipped outputted file.
Throws:
java.io.IOException - If something wrong happpens.

zipFile

public static void zipFile(java.io.File inputFile,
                           java.util.zip.ZipOutputStream zipOutputStream)
                    throws java.io.IOException
This method provides a simple zip compression for a file (not a folder).

Parameters:
inputFile - The file that must be zippede.
zipOutputStream - The target output stream that points to the location where the zip file must be placed.
Throws:
java.io.IOException - If something wrong happens.

unZipFile

public static void unZipFile(java.io.File inputFile,
                             java.io.File outputDirectory)
                      throws java.io.IOException
This method provides a simple unzip facility for a composite zip file (a zip file that contains files and folders).

Parameters:
inputFile - The zip file that must be extracted.
outputDirectory - The destination folder where the content of the input zipped file must be placed.
Throws:
java.io.IOException - If something wrong happens.


Copyright © 2006 SF.net. All Rights Reserved.