iitb.con.util
Class FileUtil

java.lang.Object
  extended by iitb.con.util.FileUtil

public class FileUtil
extends java.lang.Object

File util to retrieve file meta information


Field Summary
static java.lang.String FILE_DATA_PATH
          File data path
static java.lang.String FILE_SEPARATOR
          File separator
 
Constructor Summary
FileUtil()
           
 
Method Summary
static void copy(java.io.File src, java.io.File dst)
          Copy the file to the specified destination
static boolean createDir(java.lang.String path)
          Creates directory for the given path string
static boolean createDirForFilePathString(java.lang.String name)
          Creates the directory(-ies) for the given filepath string
static Result createFile(java.lang.String name)
          Create the file if it does not exists
static boolean deleteDir(java.io.File dir)
          Deletes the entire directory structure of the specified directory
static boolean deleteDir(java.lang.String name)
          Deletes the specified directory
static boolean deleteFile(java.lang.String name)
          Deletes the file if it exists
static java.lang.String getName(java.lang.String name)
          Gets the file name from the filepath string
static boolean isFileExists(java.lang.String name)
          Return true if file exists in the system
static boolean renameMove(java.lang.String oldFullPathName, java.lang.String newFullPathName)
          Renames and move the file to the specified destination
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_DATA_PATH

public static final java.lang.String FILE_DATA_PATH
File data path


FILE_SEPARATOR

public static final java.lang.String FILE_SEPARATOR
File separator

Constructor Detail

FileUtil

public FileUtil()
Method Detail

copy

public static void copy(java.io.File src,
                        java.io.File dst)
                 throws java.io.IOException
Copy the file to the specified destination

Parameters:
src - file source name
dst - file destination name
Throws:
java.io.IOException - on failure

createDir

public static boolean createDir(java.lang.String path)
Creates directory for the given path string

Parameters:
path - path string
Returns:
true on success

createDirForFilePathString

public static boolean createDirForFilePathString(java.lang.String name)
Creates the directory(-ies) for the given filepath string

Parameters:
name - filepath string
Returns:
true on success

createFile

public static Result createFile(java.lang.String name)
Create the file if it does not exists

Parameters:
name - file name
Returns:
Result

deleteDir

public static boolean deleteDir(java.io.File dir)
Deletes the entire directory structure of the specified directory

Parameters:
dir - directory
Returns:
true on success

deleteDir

public static boolean deleteDir(java.lang.String name)
Deletes the specified directory

Parameters:
name - directory name
Returns:
true on success

deleteFile

public static boolean deleteFile(java.lang.String name)
Deletes the file if it exists

Parameters:
name - file name
Returns:
true on success

getName

public static java.lang.String getName(java.lang.String name)
Gets the file name from the filepath string

Eg: Returns "filename.txt" for the string "/usr/test/filename.txt"

Parameters:
name - filepath string
Returns:
file name

isFileExists

public static boolean isFileExists(java.lang.String name)
Return true if file exists in the system

Parameters:
name - file name
Returns:
true if file exists

renameMove

public static boolean renameMove(java.lang.String oldFullPathName,
                                 java.lang.String newFullPathName)
Renames and move the file to the specified destination

Parameters:
oldFullPathName - old path name along with file name
newFullPathName - new path name along with file name
Returns:
true on success