net.sf.jpackit.util
Class JarUtils

java.lang.Object
  extended by net.sf.jpackit.util.JarUtils

public final class JarUtils
extends java.lang.Object

Misc utilities to work with jar archives.

Version:
$Id: JarUtils.java,v 1.10 2005/02/23 10:21:21 kamil_sham Exp $
Author:
Ignat Aleksandrov

Method Summary
static void addFileToJar(java.util.jar.JarOutputStream jar, java.io.InputStream file, java.lang.String path)
          Add file to jar with given path
static boolean checkJarValidity(java.lang.String path)
          Checks that file is valid jar archive
static java.util.jar.JarFile getExecutingJar()
          Tries to determine jar file that is used to run the application.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getExecutingJar

public static java.util.jar.JarFile getExecutingJar()
                                             throws java.io.IOException,
                                                    NotJarExecutionException
Tries to determine jar file that is used to run the application.

Returns:
currently executing jar file, or throws an exception if application was not started as "java -jar our.jar" or some error occured
Throws:
java.io.IOException
NotJarExecutionException

addFileToJar

public static void addFileToJar(java.util.jar.JarOutputStream jar,
                                java.io.InputStream file,
                                java.lang.String path)
                         throws java.io.IOException
Add file to jar with given path

Parameters:
jar - output stream to write to jar file
file - input stream to read from added file
path - internal (inside jar) path, where new file will be placed
Throws:
java.io.IOException

checkJarValidity

public static boolean checkJarValidity(java.lang.String path)
Checks that file is valid jar archive

Parameters:
path - full path to file
Returns:
true, if file is valid jar, false otherwise