org.bibalex.daf.handlers.compressionhandler
Class Zipper

java.lang.Object
  extended by org.bibalex.daf.handlers.compressionhandler.Zipper

public class Zipper
extends java.lang.Object

This class is responsible for zipping files anf folders.

Author:
Fadi.Edward

Field Summary
(package private) static int BUFFER
          Static int holds the buffer size.
 
Constructor Summary
Zipper()
           
 
Method Summary
 void ZipFile(java.lang.String fileName, java.lang.String zipFileName)
          Zips a given file into the target Zip file.
 void ZipFolder(java.lang.String folderName, java.lang.String zipFileName, boolean recursive)
          Zips a given folder into the target Zip file.
private  java.util.zip.ZipOutputStream ZipSubFolder(java.util.zip.ZipOutputStream zipOutputStream, java.lang.String folderName, java.lang.String subFolderName, boolean recursive)
          Private recusive method for Zipping subfolders.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFFER

static final int BUFFER
Static int holds the buffer size.

See Also:
Constant Field Values
Constructor Detail

Zipper

public Zipper()
Method Detail

ZipFile

public void ZipFile(java.lang.String fileName,
                    java.lang.String zipFileName)
             throws ZipperException
Zips a given file into the target Zip file.

Parameters:
fileName - fileName/Path to Zip
zipFileName - the name of the resulting Zip File.
Throws:
ZipperException - An exception explaning the reason of Zipping failure.
See Also:
ZipperException

ZipFolder

public void ZipFolder(java.lang.String folderName,
                      java.lang.String zipFileName,
                      boolean recursive)
               throws ZipperException
Zips a given folder into the target Zip file.

Parameters:
folderName - folderName/Path to Zip
zipFileName - the name of the resulting Zip File.
recursive - Boolean to indicate wether to Zip only the first level or all levels recursively.
Throws:
ZipperException - An exception explaning the reason of Zipping failure.
See Also:
ZipperException

ZipSubFolder

private java.util.zip.ZipOutputStream ZipSubFolder(java.util.zip.ZipOutputStream zipOutputStream,
                                                   java.lang.String folderName,
                                                   java.lang.String subFolderName,
                                                   boolean recursive)
                                            throws java.io.IOException
Private recusive method for Zipping subfolders.

Parameters:
zipOutputStream - the Output stream to write to.
folderName - the input subfolder.
subFolderName - the sub-folder relative path from within the folder.
recursive - indicates wether recusive or not.
Returns:
the zipOutputStream after appending the new folder.
Throws:
java.io.IOException