org.jboss.jsfunit.ant
Class Utils

java.lang.Object
  extended by org.jboss.jsfunit.ant.Utils

public class Utils
extends Object

Utility Class to handle some file io operations that are extremely useful but for some odd reason not implemeneted in the jdk itself.

Since:
1.0
Author:
Matt Wringe

Constructor Summary
Utils()
           
 
Method Summary
static void archive(File explodedArchive, File destArchive)
          Imploded an already exploded archive
static void copy(File srcfile, File destfile)
          Copy a file or directory from one location to another
static File explodeArchive(ZipFile archiveFile, File destDirectory)
          Creates an exploded war from a war archive
static String getArchiveName(ZipFile file)
          The getName() method for a ZipFile returns the full file path and not the name of the actual file.
static void unzip(ZipFile zipFile, File destDirectory)
          Unzips a zipFile to the specified directory.
static void zip(File srcDirectory, File destFile)
          Zips a directory
static void zip(File srcDirectory, File destFile, Boolean isArchive)
          Zips a directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

copy

public static void copy(File srcfile,
                        File destfile)
                 throws Exception
Copy a file or directory from one location to another

Parameters:
srcfile - The file to copy
destfile - The destination for the copied file
Throws:
Exception - If an exception occured during the copy

unzip

public static void unzip(ZipFile zipFile,
                         File destDirectory)
                  throws Exception
Unzips a zipFile to the specified directory.

Parameters:
zipFile - The file to unzip
destDirectory - The directory to unzip the file
Throws:
Exception - If an error occurs during the unzipping process

zip

public static void zip(File srcDirectory,
                       File destFile)
                throws Exception
Zips a directory

Parameters:
srcDirectory - the directory to zip
destFile - the newly created zip file
Throws:
Exception

zip

public static void zip(File srcDirectory,
                       File destFile,
                       Boolean isArchive)
                throws Exception
Zips a directory. If the directory is an exploded archive, then don't add the directory itself to the zipped file

Parameters:
srcDirectory - the directory to zip
destFile - the newly created zip file
isArchive - true if the srcDirectory is a exploded archive
Throws:
Exception - if an error occured during the zip

explodeArchive

public static File explodeArchive(ZipFile archiveFile,
                                  File destDirectory)
                           throws Exception
Creates an exploded war from a war archive

Parameters:
archiveFile - The war File
destDirectory - The directory to explode the war
Throws:
Exception - If an error occurs when exploding the war

getArchiveName

public static String getArchiveName(ZipFile file)
The getName() method for a ZipFile returns the full file path and not the name of the actual file. This method is used to retrieve the file name without the file path.

Parameters:
file - The file to get the file name

archive

public static void archive(File explodedArchive,
                           File destArchive)
                    throws Exception
Imploded an already exploded archive

Parameters:
explodedArchive - the directory of the exploded archive
destArchive - the name of the new archive to create
Throws:
Exception - if an exception occurs during the archive process


Copyright © 2007-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.