Class FileUtils

java.lang.Object
repast.simphony.util.FileUtils

public class FileUtils extends Object
Utility methods for dealing with files and directories.
Version:
$Revision$ $Date$
Author:
Nick Collier
  • Constructor Details

    • FileUtils

      public FileUtils()
  • Method Details

    • backupDir

      public static File backupDir(File dirToBackup) throws 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:
      IOException
    • backupDir

      public static File backupDir(File dirToBackup, File backupParentDir) throws 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:
      IOException
    • copyFile

      public static void copyFile(File source, File dest) throws IOException
      Copies the specified source file to the destination file.
      Parameters:
      source - the source to copy
      dest - the destination file
      Throws:
      IOException
    • copyDirs

      public static void copyDirs(File sourceDir, File destDir) throws 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:
      IOException
    • deleteIgnoreVC

      public static void deleteIgnoreVC(File file, 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(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.
    • getDataFile

      public static File getDataFile(String filename)
      Gets a file based on a certain name. The way this works is it checks the current directory for the file, then data/, demos/data/, repast/demos/data/, demos/, for the file. This is useful especially for demos that will be in the demos/ directory and ran through the Repast GUI.
      Parameters:
      filename - the name of the file to get
      Returns:
      a file object corresponding to the filename or null if the file wasn't found
    • getDataFileName

      public static String getDataFileName(String filename)
      Gets a filename based on a certain name. The way this works is it checks the current directory for the file, then data/, demos/data/, repast/demos/data/, demos/, for the file. This is useful especially for demos that will be in the demos/ directory and ran through the Repast GUI.
      Parameters:
      filename - the name of the file to get
      Returns:
      a String corresponding to the absolute path of the file or null if the file wasn't found
    • main

      public static void main(String[] args)