com.dtolabs.rundeck.core.utils
Class FileUtils

java.lang.Object
  extended by com.dtolabs.rundeck.core.utils.FileUtils

public class FileUtils
extends java.lang.Object

TODO: Consider wrapping FileUtils


Constructor Summary
FileUtils()
           
 
Method Summary
static void copyDirectory(java.io.File sourceLocation, java.io.File targetLocation)
          Copy one directory to another location (recursively)
static void copyFileStreams(java.io.File fromFile, java.io.File toFile)
          Copy a file from one location to another, and set the modification time to match.
static boolean deleteDir(java.io.File dir)
          Delete a directory recursivley.
static void fileCopy(java.io.File src, java.io.File dest, boolean overwrite)
          Copies file src to dest using nio.
static void fileRename(java.io.File file, java.lang.String newPath)
          Rename a file
static void fileRename(java.io.File file, java.lang.String newPath, java.lang.Class clazz)
          Rename a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtils

public FileUtils()
Method Detail

fileCopy

public static void fileCopy(java.io.File src,
                            java.io.File dest,
                            boolean overwrite)
                     throws java.io.IOException
Copies file src to dest using nio.

Parameters:
src -
dest -
overwrite -
Throws:
java.io.IOException

copyFileStreams

public static void copyFileStreams(java.io.File fromFile,
                                   java.io.File toFile)
                            throws java.io.IOException
Copy a file from one location to another, and set the modification time to match. (Uses java Streams).

Parameters:
fromFile -
toFile -
Throws:
java.io.IOException

deleteDir

public static boolean deleteDir(java.io.File dir)
Delete a directory recursivley. This method will delete all files and subdirectories.

Parameters:
dir - Directory to delete
Returns:
If no error occurs, true is returned. false otherwise.

fileRename

public static void fileRename(java.io.File file,
                              java.lang.String newPath,
                              java.lang.Class clazz)
Rename a file. Uses Java's nio library to use a lock and also works around a windows specific bug in File#renameTo method.

Parameters:
file - File to rename
newPath - Path for new file name
clazz - Class associated with lock
Throws:
CoreException - An CoreException is raised if any underly I/O operation fails.

fileRename

public static void fileRename(java.io.File file,
                              java.lang.String newPath)
Rename a file

Parameters:
file - File to rename
newPath - Path for new file name
Throws:
CoreException - An CoreException is raised if any underly I/O operation fails.

copyDirectory

public static void copyDirectory(java.io.File sourceLocation,
                                 java.io.File targetLocation)
                          throws java.io.IOException
Copy one directory to another location (recursively)

Parameters:
sourceLocation - Source directory
targetLocation - Target directory
Throws:
java.io.IOException - Exception raised if any underlying I/O operation fails