Class FileUtil

java.lang.Object
com.reve.utils.file.FileUtil

public class FileUtil extends Object
  • Constructor Details

    • FileUtil

      public FileUtil()
  • Method Details

    • readResourceFile

      public static String readResourceFile(String fileLocation)
      Read a text resource file and return the full content as String.
      Parameters:
      fileLocation - absolute or related name of the file to be read.
      Returns:
      the parsed content as string from the given file.
    • renameAllTempFiles

      public static void renameAllTempFiles(File watchDir)
      Renames all .tmp file to .csv file in the given directory
      Parameters:
      watchDir - Directory, where there are potential .tmp file
    • renameTmpFile

      public static boolean renameTmpFile(String fileName, boolean changeFolder, String newFolderExtension)
      Rename the given file and move to a new folder if required. Final extension of the file will be .csv This method is useful for renaming CDR file.
      Parameters:
      fileName - Original file name which will be renamed.
      changeFolder - if this value is true, renamed file will be moved to a new folder with given extension.
      newFolderExtension - if changeFolder is true, then this string will be treated as new folder's suffix extension. For example this value can be 'Processed'.
      Returns:
      true if and only if the renaming succeeded; false otherwise
    • getExtension

      public static String getExtension(String fileName)
      Get the extension of the give file name. File name can be absolute or relative.
      Parameters:
      fileName - The file name from where extension will be parsed. This value can be either absolute file path or relative file path or only file name.
      Returns:
      the extension parsed from the given file name. '.' will be excluded from the extension.
    • dropExtension

      public static String dropExtension(String fileName)
      Drop the extension part of the given file path and return only the file name without extension.
      Parameters:
      fileName - The file name with extension.
      Returns:
      the file name without extension.