VdexReload 1.1.3 API

uk.ac.reload.dweezil.util
Class ZipUtils

java.lang.Object
  extended byuk.ac.reload.dweezil.util.ZipUtils
All Implemented Interfaces:
DweezilConstants

public final class ZipUtils
extends java.lang.Object
implements DweezilConstants

Some useful Zip Utilities


Field Summary
 
Fields inherited from interface uk.ac.reload.dweezil.DweezilConstants
CR, DEBUG
 
Constructor Summary
ZipUtils()
           
 
Method Summary
static boolean addFileToZip(java.io.File file, java.lang.String entryName, java.util.zip.ZipOutputStream zOut)
          Adds a file to the Zip file
static void addFolderToZip(java.io.File rootFolder, java.io.File folder, java.util.zip.ZipOutputStream zOut, java.io.File zipFile)
          Add all files and sub-files to the Zip
static boolean addStringToZip(java.lang.String text, java.lang.String entryName, java.util.zip.ZipOutputStream zOut)
          Adds a String as a field entry to the Zip file
static java.lang.String extractZipEntry(java.io.File zipFile, java.lang.String entryName)
          Extracts a named entry out of the zip file and returns the entry as a String Returns null if weirdness happens
static java.io.File extractZipEntry(java.io.File zipFile, java.lang.String entryName, java.io.File outFile)
          Extracts a named entry out of the zip file to the specified file Returns the File ref if OK or null if something wierd happens
static java.lang.String[] getZipFileEntryNames(java.io.File zipFile)
          Gets all file names out of a zip file Returns an array of String names or null if none
static boolean unpackZip(java.io.File zipFile, java.io.File folder)
          Extracts all entries out of the zip file to the specified folder.
static boolean unpackZip(java.io.File zipFile, java.io.File folder, ReloadProgressMonitor progressMonitor)
          Extracts all entries out of the zip file to the specified folder Returns true or false to indicate if the progress cancel was pressed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipUtils

public ZipUtils()
Method Detail

addFolderToZip

public static void addFolderToZip(java.io.File rootFolder,
                                  java.io.File folder,
                                  java.util.zip.ZipOutputStream zOut,
                                  java.io.File zipFile)
                           throws DweezilZipException
Add all files and sub-files to the Zip

Parameters:
rootFolder - the root folder
folder - the folder to add to the zip
zOut - the zip output stream
zipFile - the zip file
Throws:
DweezilZipException

addFileToZip

public static boolean addFileToZip(java.io.File file,
                                   java.lang.String entryName,
                                   java.util.zip.ZipOutputStream zOut)
                            throws DweezilZipException
Adds a file to the Zip file

Parameters:
file - the file to add to the zip
entryName - the name of the new zip entry
zOut - the zip output stream
Throws:
DweezilZipException

addStringToZip

public static boolean addStringToZip(java.lang.String text,
                                     java.lang.String entryName,
                                     java.util.zip.ZipOutputStream zOut)
                              throws DweezilZipException
Adds a String as a field entry to the Zip file

Parameters:
text - the string to add as a field entry to the zip file
entryName - the name of the new zip entry
zOut - the zip output stream
Throws:
DweezilZipException

extractZipEntry

public static java.lang.String extractZipEntry(java.io.File zipFile,
                                               java.lang.String entryName)
                                        throws DweezilZipException
Extracts a named entry out of the zip file and returns the entry as a String Returns null if weirdness happens

Parameters:
zipFile - the zip file
entryName - the name of the new zip entry
Throws:
DweezilZipException

extractZipEntry

public static java.io.File extractZipEntry(java.io.File zipFile,
                                           java.lang.String entryName,
                                           java.io.File outFile)
                                    throws DweezilZipException
Extracts a named entry out of the zip file to the specified file Returns the File ref if OK or null if something wierd happens

Parameters:
zipFile - the zip file from which you extract the named entry
entryName - the name of the new zip entry
outFile - the specified zip file to which you add the entry
Returns:
the file ref if OK or null if something wierd happens
Throws:
DweezilZipException

getZipFileEntryNames

public static java.lang.String[] getZipFileEntryNames(java.io.File zipFile)
                                               throws DweezilZipException
Gets all file names out of a zip file Returns an array of String names or null if none

Parameters:
zipFile - the zip file from which we are trying to get all file names
Returns:
an array of String names or null if none
Throws:
DweezilZipException

unpackZip

public static boolean unpackZip(java.io.File zipFile,
                                java.io.File folder)
                         throws DweezilZipException
Extracts all entries out of the zip file to the specified folder. Returns true or false to indicate if the progress was OK or not.

Parameters:
zipFile - the zip file concerned
folder - the folder into which you want to extract the contents of the zip file
Returns:
true if the progres was OK, false if not
Throws:
DweezilZipException

unpackZip

public static boolean unpackZip(java.io.File zipFile,
                                java.io.File folder,
                                ReloadProgressMonitor progressMonitor)
                         throws DweezilZipException
Extracts all entries out of the zip file to the specified folder Returns true or false to indicate if the progress cancel was pressed

Parameters:
zipFile - the zip file concerned
folder - the folder into which you want to extract the contents of the zip file
progressMonitor - the progress monitor showing you the progress of the unzipping
Returns:
true if the progres was OK, false if the progress cancel was pressed
Throws:
DweezilZipException

VdexReload 1.1.3 API