org.openorb.util
Class ZipUtil

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

public class ZipUtil
extends java.lang.Object

This class provides utilities to manage a zip file.

Version:
$Revision: 1.5 $ $Date: 2002/07/14 19:12:41 $
Author:
Jerome Daniel

Constructor Summary
ZipUtil()
           
 
Method Summary
static void addZipFileToZip(java.util.zip.ZipEntry src_entry, java.util.zip.ZipFile inputZip, java.lang.String dst_name, java.util.zip.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, java.lang.String file)
          This function tests if a zip contains a file specified as parameter.
static void copy(ZipHandle src, ZipHandle dst, java.lang.String[] no_copy_list)
          Make a copy of a zip file.
static ZipHandle CreateZip(java.lang.String name)
          Create a zip file.
static byte[] getFileContent(ZipHandle handle, java.lang.String file)
          Extract a file and return its contents.
static void insert(java.lang.String src_name, java.lang.String dst_name, ZipHandle dest)
          This function adds a file to a zip file.
static ZipHandle OpenZip(java.lang.String name)
          Open a zip file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipUtil

public ZipUtil()
Method Detail

CreateZip

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

OpenZip

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

CloseZip

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

insert

public static void insert(java.lang.String src_name,
                          java.lang.String dst_name,
                          ZipHandle dest)
                   throws java.io.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:
java.io.IOException - When the file can't be inserted into the zip file.

addZipFileToZip

public static void addZipFileToZip(java.util.zip.ZipEntry src_entry,
                                   java.util.zip.ZipFile inputZip,
                                   java.lang.String dst_name,
                                   java.util.zip.ZipOutputStream outputZip)
                            throws java.io.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:
java.io.IOException - When the source can't be read or the destination can't be written.

copy

public static void copy(ZipHandle src,
                        ZipHandle dst,
                        java.lang.String[] no_copy_list)
                 throws java.io.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:
java.io.IOException - When either the read or the write fails.

containsFile

public static boolean containsFile(ZipHandle handle,
                                   java.lang.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,
                                    java.lang.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.