net.yagga.util
Class Unzip

java.lang.Object
  |
  +--net.yagga.util.Unzip

public class Unzip
extends java.lang.Object

Unzipper class. It unzipz standrd ZIP files as well as Jar files. It was a hell of a code writing...
THe typical usage is as follows.. Unzip u=new Unzip("archive.zip","/usr/tmp");
u.uncompress(false); //verbose set to false..

Or..if we want to trAck esxtraction..
while((ret=u.chunkuncompress(false,true,true))!=-1){
System.out.println(ret);
}

Author:
Walter Gamba

Field Summary
(package private)  java.util.zip.ZipInputStream chunkzis
          chunked
private  java.util.Vector createdDirs
           
(package private)  long currSize
           
(package private)  java.lang.String destDir
           
private  java.util.Vector extractedFiles
          Store here extracted files..
(package private)  long maxSize
           
(package private)  java.lang.String zipFile
           
 
Constructor Summary
Unzip(java.lang.String zFile, java.lang.String dDir)
           
 
Method Summary
 int chunkuncompress(boolean verbose, boolean acc, boolean percent)
          Uncompress file chunked.. so to get track of the progress of the unzipping process
 java.util.Vector getCreatedDirsList()
           
 java.util.Vector getExtractedFilesList()
           
 long getMax()
           
private  void getStats()
           
private  void getStats2()
           
private  java.util.zip.ZipInputStream getZIS()
           
static void main(java.lang.String[] argv)
           
 void startChunking()
           
 void uncompress(boolean verbose)
          Use this to uncompress in a straight way a ZIP/JAR file
 void uncompress(java.util.zip.ZipEntry _ze, boolean verbose)
           
private  void writeUncompressedFile(java.util.zip.ZipEntry ze, byte[] buffer, boolean verbose)
          Actually write an extracted file to file system.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

extractedFiles

private java.util.Vector extractedFiles
Store here extracted files..

createdDirs

private java.util.Vector createdDirs

zipFile

java.lang.String zipFile

destDir

java.lang.String destDir

maxSize

long maxSize

currSize

long currSize

chunkzis

java.util.zip.ZipInputStream chunkzis
chunked
Constructor Detail

Unzip

public Unzip(java.lang.String zFile,
             java.lang.String dDir)
Method Detail

main

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

getExtractedFilesList

public java.util.Vector getExtractedFilesList()
Returns:
a Vector of File containing extracted files.

getCreatedDirsList

public java.util.Vector getCreatedDirsList()
Returns:
a Vector of File containing created directories.

getMax

public long getMax()

getStats

private void getStats()

getStats2

private void getStats2()

startChunking

public void startChunking()

uncompress

public void uncompress(java.util.zip.ZipEntry _ze,
                       boolean verbose)

uncompress

public void uncompress(boolean verbose)
Use this to uncompress in a straight way a ZIP/JAR file
Parameters:
verbose - print progress informations

getZIS

private java.util.zip.ZipInputStream getZIS()

chunkuncompress

public int chunkuncompress(boolean verbose,
                           boolean acc,
                           boolean percent)
Uncompress file chunked.. so to get track of the progress of the unzipping process
Parameters:
verbose - display progress info
acc - add size extracted to last size returned..
percent - transform progress values to percent values (if true) or get raw data ifa false
Returns:
return the size of extracted data in bytes.. if percent is true return a percentage returns -1 if there is an error.

writeUncompressedFile

private void writeUncompressedFile(java.util.zip.ZipEntry ze,
                                   byte[] buffer,
                                   boolean verbose)
Actually write an extracted file to file system. Stores created dirs and files in vectors> Such vectors can later be retrieved.
Parameters:
ze - a ZipEntry the file/directory to write
buffer -  
verbose -