Package repast.simphony.util
Class FileUtils
java.lang.Object
repast.simphony.util.FileUtils
Utility methods for dealing with files and directories.
- Version:
- $Revision$ $Date$
- Author:
- Nick Collier
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic File
Backups the specified directory into a new directory in the same parent directory.static File
Backs up the specified directory into a new directory in the specified parent directory.static void
Recursively copy all the files from the source directory to the destination directory.static void
Copies the specified source file to the destination file.static void
Deletes the specified file.static void
deleteIgnoreVC
(File file, String... filesToIgnore) Deletes the specified file.static File
getDataFile
(String filename) Gets a file based on a certain name.static String
getDataFileName
(String filename) Gets a filename based on a certain name.static void
-
Constructor Details
-
FileUtils
public FileUtils()
-
-
Method Details
-
backupDir
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
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 backupbackupParentDir
- the parent directory of the new backup directory- Returns:
- the backup directory
- Throws:
IOException
-
copyFile
Copies the specified source file to the destination file.- Parameters:
source
- the source to copydest
- the destination file- Throws:
IOException
-
copyDirs
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 directorydestDir
- the destination directory- Throws:
IOException
-
deleteIgnoreVC
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
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
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
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
-