anl.aida.util
Class FileUtilities

java.lang.Object
  extended by anl.aida.util.FileUtilities

public class FileUtilities
extends java.lang.Object

Utility methods for dealing with files and directories.

Version:
$Revision$ $Date$

Constructor Summary
FileUtilities()
           
 
Method Summary
static java.io.File backupDir(java.io.File dirToBackup)
          Backups the specified directory into a new directory in the same parent directory.
static java.io.File backupDir(java.io.File dirToBackup, java.io.File backupParentDir)
          Backs up the specified directory into a new directory in the specified parent directory.
static void copyDirs(java.io.File sourceDir, java.io.File destDir)
          Recursively copy all the files from the source directory to the destination directory.
static void copyDirs(java.io.File sourceDir, java.io.File destDir, java.io.FileFilter filter)
          Recursively copy all the files from the source directory to the destination directory.
static void copyFile(java.io.File source, java.io.File dest)
          Copies the specified source file to the destination file.
static void delete(java.io.File file)
          Deletes the specified file.
static void deleteIgnoreVC(java.io.File file, java.lang.String... filesToIgnore)
          Deletes the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtilities

public FileUtilities()
Method Detail

backupDir

public static java.io.File backupDir(java.io.File dirToBackup)
                              throws java.io.IOException
Backups the specified directory into a new directory in the same parent directory. The backed up directory name will be a form of the name of the dirToBack + .bak + an optional number. The number will be increased until a unique name is found.

Parameters:
dirToBackup -
Returns:
the backup directory
Throws:
java.io.IOException

backupDir

public static java.io.File backupDir(java.io.File dirToBackup,
                                     java.io.File backupParentDir)
                              throws java.io.IOException
Backs up the specified directory into a new directory in the specified parent directory. The backed up directory name will be a form of the name of the dirToBack + .bak + an optional number. The number will be increased until a unique name is found.

Parameters:
dirToBackup - the directory to backup
backupParentDir - the parent directory of the new backup directory
Returns:
the backup directory
Throws:
java.io.IOException

copyFile

public static void copyFile(java.io.File source,
                            java.io.File dest)
                     throws java.io.IOException
Copies the specified source file to the destination file.

Parameters:
source - the source to copy
dest - the destination file
Throws:
java.io.IOException

copyDirs

public static void copyDirs(java.io.File sourceDir,
                            java.io.File destDir)
                     throws java.io.IOException
Recursively copy all the files from the source directory to the destination directory. If the destination directory does not exist it will be created.

Parameters:
sourceDir - the source directory
destDir - the destination directory
Throws:
java.io.IOException

copyDirs

public static void copyDirs(java.io.File sourceDir,
                            java.io.File destDir,
                            java.io.FileFilter filter)
                     throws java.io.IOException
Recursively copy all the files from the source directory to the destination directory. If the destination directory does not exist it will be created.

Parameters:
sourceDir - the source directory
destDir - the destination directory
filter - determines what is copied out of the source directory
Throws:
java.io.IOException

deleteIgnoreVC

public static void deleteIgnoreVC(java.io.File file,
                                  java.lang.String... filesToIgnore)
Deletes the specified file. If file is a directory, then recursively delete the contents of that directory and the directory itself, unless the directory is a version control dir -- .svn or .cvs.

Parameters:
file - the file or directory to delete.

delete

public static void delete(java.io.File file)
Deletes the specified file. If file is a directory, then recursively delete the contents of that directory and the directory itself.

Parameters:
file - the file or directory to delete.