com.ibm.team.fvt.tests.utils
Class FileUtil

java.lang.Object
  extended by com.ibm.team.fvt.tests.utils.FileUtil

public class FileUtil
extends java.lang.Object

Utilities to manipulate files and directories on disk through java.io

Note that this code has been initially copied from JFS team...


Constructor Summary
FileUtil()
           
 
Method Summary
static void copyDir(java.io.File sourceDir, java.io.File destDir)
          Copy all files from source dircetory to destination directory.
static java.io.File copyFile(java.io.File sourceFile, java.io.File destDir)
          Copy the given source file to the given destination directory.
static java.io.File copyFile(java.io.File sourceFile, java.io.File destDir, java.lang.String destFile)
          Copy the given source file to the given destination directory with a different name.
static void deleteFile(java.io.File file)
          Delete the given file.
static java.lang.String readFileContent(java.io.File file)
          Read the content of the gievn file, assuming it's a text file.
static void rmdir(java.io.File dir)
          Delete an entire directory hierarchy including all files.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileUtil

public FileUtil()
Method Detail

copyDir

public static void copyDir(java.io.File sourceDir,
                           java.io.File destDir)
                    throws java.io.IOException
Copy all files from source dircetory to destination directory.

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

copyFile

public static java.io.File copyFile(java.io.File sourceFile,
                                    java.io.File destDir)
                             throws java.io.IOException
Copy the given source file to the given destination directory.

Parameters:
sourceFile - The file to copy
destDir - The directory where to copy the file
Returns:
The copied file as a File
Throws:
java.io.IOException

copyFile

public static java.io.File copyFile(java.io.File sourceFile,
                                    java.io.File destDir,
                                    java.lang.String destFile)
                             throws java.io.IOException
Copy the given source file to the given destination directory with a different name.

Parameters:
sourceFile - The file to copy
destDir - The directory where to copy the file
destFile - The new file name
Returns:
The copied file as a File
Throws:
java.io.IOException

deleteFile

public static void deleteFile(java.io.File file)
                       throws java.io.IOException
Delete the given file.

Note that if the deletion fails, it's performed again until success or five consecutive failures.

Parameters:
file - The file to delete
Throws:
java.io.IOException

readFileContent

public static java.lang.String readFileContent(java.io.File file)
                                        throws java.io.IOException
Read the content of the gievn file, assuming it's a text file.

Parameters:
file - The file to read
Returns:
The file content as a String.
Throws:
java.io.IOException

rmdir

public static void rmdir(java.io.File dir)
                  throws java.io.IOException
Delete an entire directory hierarchy including all files.

Parameters:
dir - The directory to delete
Throws:
java.io.IOException