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 Details

    • FileManipulator

      public FileManipulator()
  • Method Details

    • 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: