org.wso2.carbon.utils
Class FileManipulator

java.lang.Object
  extended by org.wso2.carbon.utils.FileManipulator

public class FileManipulator
extends Object

A set of useful utility for File manipulation operations


Constructor Summary
FileManipulator()
           
 
Method Summary
static void copyDir(File srcDir, File dstDir)
          Copies all files under srcDir to dstDir.
static void copyFile(File src, File dst)
          Copies src file to dst file.
static void copyFileToDir(File src, File dst)
          Copies src file to dst directory.
static boolean deleteDir(File dir)
          Deletes all files and subdirectories under dir.
static void deleteDir(String directory)
           
static File[] getMatchingFiles(String sourceDir, String fileNamePrefix, String extension)
          Get the list of file with a prefix of fileNamePrefix & an extension of extension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileManipulator

public FileManipulator()
Method Detail

deleteDir

public static boolean deleteDir(File dir)
Deletes all files and subdirectories under dir. Returns true if all deletions were successful. If a deletion fails, the method stops attempting to delete and returns false.

Parameters:
dir - The directory to be deleted
Returns:
true if the directory and its descendents were deleted

copyDir

public static void copyDir(File srcDir,
                           File dstDir)
                    throws IOException
Copies all files under srcDir to dstDir. If dstDir does not exist, it will be created.

Parameters:
srcDir - The source dir
dstDir - The destination dir
Throws:
IOException - If an error occrs while copying

copyFile

public static void copyFile(File src,
                            File dst)
                     throws IOException
Copies src file to dst file. If the dst file does not exist, it is created

Parameters:
src - The source file
dst - The destiination file
Throws:
IOException - If an Exception occurs while copying

copyFileToDir

public static void copyFileToDir(File src,
                                 File dst)
                          throws IOException
Copies src file to dst directory. If the dst directory does not exist, it is created

Parameters:
src - The file to be copied
dst - The destination directory to which the file has to be copied
Throws:
IOException - If an error occurs while copying

getMatchingFiles

public static File[] getMatchingFiles(String sourceDir,
                                      String fileNamePrefix,
                                      String extension)
Get the list of file with a prefix of fileNamePrefix & an extension of extension

Parameters:
sourceDir - The directory in which to search the files
fileNamePrefix - The prefix to look for
extension - The extension to look for
Returns:
The list of file with a prefix of fileNamePrefix & an extension of extension

deleteDir

public static void deleteDir(String directory)
Parameters:
directory - The directory to be deleted
See Also:
deleteDir(File)


Copyright © 2014 WSO2 Inc. All rights reserved.