Package org.wso2.carbon.utils
Class FileManipulator
java.lang.Object
org.wso2.carbon.utils.FileManipulator
A set of useful utility for File manipulation operations
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCopies all files under srcDir to dstDir.static voidCopies src file to dst file.static voidcopyFileToDir(File src, File dst) Copies src file to dst directory.static booleanDeletes all files and subdirectories under dir.static voidstatic File[]getMatchingFiles(String sourceDir, String fileNamePrefix, String extension) Get the list of file with a prefix offileNamePrefix& an extension ofextension
-
Constructor Details
-
FileManipulator
public FileManipulator()
-
-
Method Details
-
deleteDir
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
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
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
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
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
- Parameters:
directory- The directory to be deleted- See Also:
-