com.atomikos.util
Class JarArchive

java.lang.Object
  extended by com.atomikos.util.JarArchive

public class JarArchive
extends Object

Copyright © 2003, Atomikos. All rights reserved. A JAR file utility class.


Constructor Summary
JarArchive(File stageFolder)
          Create a new instance.
 
Method Summary
 void add(File file)
          Add a file to the stage folder.
protected  void add(File file, File destination)
           
protected  void addEntryToJar(JarOutputStream jarOut, File entry)
           
 void addJar(File jarFile)
          Add a jar file to the stage folder.
 void addToMetaInf(File file)
          Add a file to the META-INF directory for the jar.
 File createJar(String name, File destinationFolder)
          Create a new jar file containing everything that was added so far.
 File getStageFolder()
          Get the stage folder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarArchive

public JarArchive(File stageFolder)
           throws IOException
Create a new instance.

Parameters:
stageFolder - Where to place temporary files.
Throws:
IOException - If stageFolder is not a directory.
Method Detail

getStageFolder

public File getStageFolder()
Get the stage folder.

Returns:
File The folder.

add

protected void add(File file,
                   File destination)
            throws IOException
Throws:
IOException

add

public void add(File file)
         throws IOException
Add a file to the stage folder.

Parameters:
file - The file to add.
Throws:
IOException - On IO errors.

addToMetaInf

public void addToMetaInf(File file)
                  throws IOException
Add a file to the META-INF directory for the jar.

Parameters:
file - The file to add. Only the file name will be taken into account; any parent folders are ignored.
Throws:
IOException - On error.

addJar

public void addJar(File jarFile)
            throws IOException
Add a jar file to the stage folder. This file will first be extracted.

Parameters:
jarFile - The jar file to add.
Throws:
IOException - If the file is not a jar file, or if it could not be added.

createJar

public File createJar(String name,
                      File destinationFolder)
               throws IOException
Create a new jar file containing everything that was added so far.

Parameters:
name - The name of the archive file.
destinationFolder - The destination for the archive file.
Returns:
File The resulting file.
Throws:
IOException - If the archive could not be created.

addEntryToJar

protected void addEntryToJar(JarOutputStream jarOut,
                             File entry)
                      throws IOException
Throws:
IOException