info.joseluismartin.util
Class ZipFileUtils

java.lang.Object
  extended by info.joseluismartin.util.ZipFileUtils

public abstract class ZipFileUtils
extends Object

Utility library to manage Zip files.

Author:
Jose Luis Martin -(jlm@joseluismartin.info)

Constructor Summary
ZipFileUtils()
           
 
Method Summary
static void addFile(File zipFile, File addFile)
          Add File to Zip File
static byte[] readEntryAsByteArray(ZipFile file, ZipEntry ze)
          Read a Zip Entry as byte[]
static void unzip(ZipFile file, String dirname)
          Unzip file to dirname
static void zip(File[] files, String zipFilename)
          Create a zip file with files
static void zip(File file, String zipFilename)
          Create a zip file from zipFileName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipFileUtils

public ZipFileUtils()
Method Detail

unzip

public static void unzip(ZipFile file,
                         String dirname)
Unzip file to dirname

Parameters:
file - file to unzip
dirname - dir name to store unzipped entries

zip

public static void zip(File file,
                       String zipFilename)
                throws Exception
Create a zip file from zipFileName

Parameters:
file - to compress
zipFilename - to create
Throws:
Exception - if fail

zip

public static void zip(File[] files,
                       String zipFilename)
                throws Exception
Create a zip file with files

Parameters:
files - to compress
zipFilename - zip file to create
Throws:
Exception - if fail

addFile

public static void addFile(File zipFile,
                           File addFile)
                    throws Exception
Add File to Zip File

Parameters:
zipFile - to add on
addFile - file to add
Throws:
Exception - if fail

readEntryAsByteArray

public static byte[] readEntryAsByteArray(ZipFile file,
                                          ZipEntry ze)
                                   throws IOException
Read a Zip Entry as byte[]

Parameters:
file - zip file
ze - zip entry
Returns:
byte with data
Throws:
IOException - if fail


Copyright © 2012 JDAL. All Rights Reserved.