NetCharts Server

netcharts.server.util
Class JarUtils

java.lang.Object
  |
  +--netcharts.server.util.JarUtils

public class JarUtils
extends java.lang.Object

Utilities for reading/writing/updating jars. Very raw. Much left to be done.

Since:
4.6

Constructor Summary
JarUtils()
           
 
Method Summary
static java.util.jar.JarOutputStream addFileToJar(java.lang.String jarName, java.lang.String fileName, byte[] fileContents)
          Addes a file to a jar when supplied with the file name (jar entry name) and the file's contents.
static java.util.jar.JarOutputStream addFileToJar(java.lang.String jarName, java.lang.String fileName, byte[] fileContents, java.util.jar.JarOutputStream jar, boolean closeJar)
          Adds a file to a jar when supplied with the file name (jar entry name) and the file's contents; returns the unclosed JarOutputStream if requested
static java.util.jar.JarOutputStream addFileToJar(java.lang.String jarName, java.lang.String fileNameInJar, java.lang.String filePath, java.util.jar.JarOutputStream jar, boolean closeJar)
          Adds the named file to the jar.
static void closeJar(java.util.jar.JarOutputStream jar)
          Closes a JarOutputStream returned by one of the other methods
static java.util.jar.JarOutputStream copyJarExceptFile(java.lang.String fromJarFileName, java.lang.String toJarFileName, java.lang.String exceptFileName, boolean closeJar)
          Creates a new jar with identical contents of the old jar except the named file is not copied
static java.lang.String extractFileFromJar(java.lang.String entryName, java.lang.String jarName)
          Extracts the given file from the jar and returns the file contents as a String
static void extractFileFromJar(java.lang.String entryName, java.lang.String jarName, java.lang.String destFileName)
          Extracts a file from a jar and writes the file to the given destination filename
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarUtils

public JarUtils()
Method Detail

copyJarExceptFile

public static java.util.jar.JarOutputStream copyJarExceptFile(java.lang.String fromJarFileName,
                                                              java.lang.String toJarFileName,
                                                              java.lang.String exceptFileName,
                                                              boolean closeJar)
                                                       throws java.io.IOException
Creates a new jar with identical contents of the old jar except the named file is not copied
Throws:
java.io.IOException -  

extractFileFromJar

public static void extractFileFromJar(java.lang.String entryName,
                                      java.lang.String jarName,
                                      java.lang.String destFileName)
                               throws java.io.IOException
Extracts a file from a jar and writes the file to the given destination filename
Parameters:
entryName -  
jarName -  
destFileName -  
Throws:
java.io.IOException -  

extractFileFromJar

public static java.lang.String extractFileFromJar(java.lang.String entryName,
                                                  java.lang.String jarName)
                                           throws java.io.IOException
Extracts the given file from the jar and returns the file contents as a String
Parameters:
entryName -  
jarName -  
Returns:
 
Throws:
java.io.IOException -  

addFileToJar

public static java.util.jar.JarOutputStream addFileToJar(java.lang.String jarName,
                                                         java.lang.String fileName,
                                                         byte[] fileContents)
                                                  throws java.io.IOException
Addes a file to a jar when supplied with the file name (jar entry name) and the file's contents.
Parameters:
jarName -  
fileName -  
fileContents -  
Returns:
 
Throws:
java.io.IOException -  

addFileToJar

public static java.util.jar.JarOutputStream addFileToJar(java.lang.String jarName,
                                                         java.lang.String fileName,
                                                         byte[] fileContents,
                                                         java.util.jar.JarOutputStream jar,
                                                         boolean closeJar)
                                                  throws java.io.IOException
Adds a file to a jar when supplied with the file name (jar entry name) and the file's contents; returns the unclosed JarOutputStream if requested
Parameters:
jarName -  
fileName -  
fileContents -  
jar -  
closeJar -  
Returns:
 
Throws:
java.io.IOException -  

addFileToJar

public static java.util.jar.JarOutputStream addFileToJar(java.lang.String jarName,
                                                         java.lang.String fileNameInJar,
                                                         java.lang.String filePath,
                                                         java.util.jar.JarOutputStream jar,
                                                         boolean closeJar)
                                                  throws java.io.IOException
Adds the named file to the jar. If a non-null JarOutputStream is passed in, it is used, otherwise a new one is created, which will overwrite an existing jar.
Parameters:
jarName - the jar to add to
fileNameInJar - file name to add to the jar; any path component will be reflected within the jar
filePath - fully-qualified name fo the file to read
jar - optional open JarOutputStream; if null a new one will be created
closeJar - whether the JarOutputStream should be closed after the file is added
Returns:
an open JarOutputStream if the closeJar param is true, otherwise null
Throws:
java.io.IOException -  

closeJar

public static void closeJar(java.util.jar.JarOutputStream jar)
                     throws java.io.IOException
Closes a JarOutputStream returned by one of the other methods
Parameters:
jar -  
Throws:
java.io.IOException -  

NetCharts Server


Visual Mining, Inc.
15825 Shady Grove Rd.
Suite 20
Rockville, MD 20850
800.308.0731
301.947.8293 FAX

Copyright © Visual Mining, Inc. 1996 - 2007
All Rights Reserved.

NetCharts Server TM is a registered trademark of Visual Mining, Inc. Other brands and their products are trademarks of their respective holders.

Last Modified: Jun 14, 2007