org.openorb.util
Class ZipUtil

java.lang.Object
  |
  +--org.openorb.util.ZipUtil

public final class ZipUtil
extends Object

This class provides utilities to manage a zip file.

Version:
$Revision: 1.5 $ $Date: 2004/07/20 23:50:43 $
Author:
Jerome Daniel

Method Summary
static void addZipFileToZip(ZipEntry src_entry, ZipFile inputZip, String dst_name, ZipOutputStream outputZip)
          This function adds a zip file entry to another zip.
static void closeZip(ZipHandle handle)
          Close a zip file
static boolean containsFile(ZipHandle handle, String file)
          This function tests if a zip contains a file specified as parameter.
static void copy(ZipHandle src, ZipHandle dst, String[] no_copy_list)
          Make a copy of a zip file.
static ZipHandle createZip(String name)
          Create a zip file.
static byte[] getFileContent(ZipHandle handle, String file)
          Extract a file and return its contents.
static void insert(String src_name, String dst_name, ZipHandle dest)
          This function adds a file to a zip file.
static ZipHandle openZip(String name)
          Open a zip file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createZip

public static ZipHandle createZip(String name)
                           throws IOException
Create a zip file.
Parameters:
name - The name for the zip file to create.
Returns:
A handle to the zip file.
Throws:
IOException - When the FileOutputStream can not be created.

openZip

public static ZipHandle openZip(String name)
                         throws IOException
Open a zip file.
Parameters:
name - The name for the zip file to open.
Returns:
A handle to the zip file.
Throws:
IOException - ????.

closeZip

public static void closeZip(ZipHandle handle)
                     throws IOException
Close a zip file
Parameters:
handle - The handle of the zip file to create.
Throws:
IOException - When the handle can't be closed.

insert

public static void insert(String src_name,
                          String dst_name,
                          ZipHandle dest)
                   throws IOException
This function adds a file to a zip file.
Parameters:
src_name - The name of the source file.
dst_name - The name of the destination file.
dest - The handle of the zip file into which to insert the file.
Throws:
IOException - When the file can't be inserted into the zip file.

addZipFileToZip

public static void addZipFileToZip(ZipEntry src_entry,
                                   ZipFile inputZip,
                                   String dst_name,
                                   ZipOutputStream outputZip)
                            throws IOException
This function adds a zip file entry to another zip.
Parameters:
src_entry - The entry in the source zip file.
inputZip - The source zip file.
dst_name - The name in the destination zip file.
outputZip - The output stream of the destination zip file.
Throws:
IOException - When the source can't be read or the destination can't be written.

copy

public static void copy(ZipHandle src,
                        ZipHandle dst,
                        String[] no_copy_list)
                 throws IOException
Make a copy of a zip file.
Parameters:
src - The handle of the source zip file.
dst - The handle of the destination zip file.
no_copy_list - An array of filenames that should be left out while copying.
Throws:
IOException - When either the read or the write fails.

containsFile

public static boolean containsFile(ZipHandle handle,
                                   String file)
This function tests if a zip contains a file specified as parameter.
Parameters:
handle - The handle of the zip file to be tested.
file - The file to check the zip file for.
Returns:
True if the file exists in the zip file, false otherwise.

getFileContent

public static byte[] getFileContent(ZipHandle handle,
                                    String file)
Extract a file and return its contents.
Parameters:
handle - The handle of the zip file.
file - The file to extract.
Returns:
The byte array of the extracted file.