org.ourgrid.common.util
Class SimpleZip

java.lang.Object
  extended by org.ourgrid.common.util.SimpleZip

public class SimpleZip
extends java.lang.Object

This class is supposed to zip files into a .zip file and extract them without creating parent directories. Algorithms used here are based on the ones at http://www.javalobby.org/java/forums/t16299.html

Version:
2.0 Created on 08/02/2006

Constructor Summary
SimpleZip()
           
 
Method Summary
static void main(java.lang.String[] args)
          Main
static void unzipIt(java.io.File file, java.lang.String destinationDirectory)
          Unzips without creating parent directories.
static void zipIt(java.lang.String[] filesToZip, java.lang.String zipFileName)
          Zips files.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleZip

public SimpleZip()
Method Detail

zipIt

public static void zipIt(java.lang.String[] filesToZip,
                         java.lang.String zipFileName)
                  throws java.io.IOException
Zips files.

Parameters:
filesToZip - Filepaths to zip.
zipFileName - The zip file path with respective name.
Throws:
java.io.IOException - Thrown if an IO exception occurs while zipping files.

unzipIt

public static void unzipIt(java.io.File file,
                           java.lang.String destinationDirectory)
                    throws java.io.IOException
Unzips without creating parent directories.

Parameters:
file - The zip file to be extracted.
destinationDirectory - The destination directory where extracted files will be placed.
Throws:
java.io.IOException - Thrown if an IO exception occurs while unzipping files.

main

public static void main(java.lang.String[] args)
Main

Parameters:
args - The first parameter is either "-c" or "-x" (to compress or extract, respectively). If "-c", the second parameter is the zip file path, and the others are file paths to compress (separated by space). If "-x", the second parameter is the zip file path to unzip, and the other is the destination directory where the will be placed.