gov.nih.nci.cagrid.common
Class JarUtilities

java.lang.Object
  extended by gov.nih.nci.cagrid.common.JarUtilities

public class JarUtilities
extends java.lang.Object

JarUtilities Utilities to manipulate jar files

Version:
$Id$
Author:
David W. Ervin

Constructor Summary
JarUtilities()
           
 
Method Summary
static java.lang.StringBuffer getFileContents(java.util.jar.JarFile jar, java.lang.String entryName)
          Gets the contents of a jar entry as a StringBuffer
static void insertEntry(java.io.File jarFile, java.lang.String entryName, byte[] data)
          Inserts an entry in a Jar file.
static void jarDirectory(java.io.File dir, java.io.File jarFile)
          Places the contents of a directory in a Jar file
static byte[] removeJarEntry(java.util.jar.JarFile jar, java.lang.String entryName)
          Removes an entry from a jar file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarUtilities

public JarUtilities()
Method Detail

getFileContents

public static java.lang.StringBuffer getFileContents(java.util.jar.JarFile jar,
                                                     java.lang.String entryName)
                                              throws java.io.IOException
Gets the contents of a jar entry as a StringBuffer

Parameters:
jar - The jar to extract from
entryName - The name of the entry to be extracted
Returns:
The contents of a jar entry, or null if no such entry exists
Throws:
java.io.IOException

removeJarEntry

public static byte[] removeJarEntry(java.util.jar.JarFile jar,
                                    java.lang.String entryName)
                             throws java.io.IOException
Removes an entry from a jar file

Parameters:
jar - The jar file
entryName - The name of the entry to remove
Returns:
The data of the jar with the entry removed
Throws:
java.io.IOException

jarDirectory

public static void jarDirectory(java.io.File dir,
                                java.io.File jarFile)
                         throws java.io.IOException
Places the contents of a directory in a Jar file

Parameters:
dir - The directory
jarFile - The jar file
Throws:
java.io.IOException

insertEntry

public static void insertEntry(java.io.File jarFile,
                               java.lang.String entryName,
                               byte[] data)
                        throws java.io.IOException
Inserts an entry in a Jar file. If an entry with the given name is found, it will be replaced with the new one.

Parameters:
jarFile - The jar file to be appended
entryName - The name of the new entry
data - The data to add to the zip
Throws:
java.io.IOException