Package org.wso2.carbon.utils
Class FileManipulator
- java.lang.Object
-
- org.wso2.carbon.utils.FileManipulator
-
public class FileManipulator extends Object
A set of useful utility for File manipulation operations
-
-
Constructor Summary
Constructors Constructor Description FileManipulator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopyDir(File srcDir, File dstDir)Copies all files under srcDir to dstDir.static voidcopyFile(File src, File dst)Copies src file to dst file.static voidcopyFileToDir(File src, File dst)Copies src file to dst directory.static booleandeleteDir(File dir)Deletes all files and subdirectories under dir.static voiddeleteDir(String directory)static File[]getMatchingFiles(String sourceDir, String fileNamePrefix, String extension)Get the list of file with a prefix offileNamePrefix& an extension ofextension
-
-
-
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 dirdstDir- 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 filedst- 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 copieddst- 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 offileNamePrefix& an extension ofextension- Parameters:
sourceDir- The directory in which to search the filesfileNamePrefix- The prefix to look forextension- The extension to look for- Returns:
- The list of file with a prefix of
fileNamePrefix& an extension ofextension
-
deleteDir
public static void deleteDir(String directory)
- Parameters:
directory- The directory to be deleted- See Also:
deleteDir(File)
-
-