Package com.reve.utils.file
Class FileUtil
java.lang.Object
com.reve.utils.file.FileUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FilecreateTempFile(String fileNameInsideJar) Create a temp file from the file inside the jar.static StringdropExtension(String fileName) Drop the extension part of the given file path and return only the file name without extension.static StringgetExtension(String fileName) Get the extension of the give file name.static StringreadResourceFile(String fileLocation) Read a text resource file and return the full content as String.static StringreadResourceFile(String fileLocation, String lineSeparator) Read a text resource file and return the full content as String.static voidrenameAllTempFiles(File watchDir) Renames all .tmp file to .csv file in the given directorystatic booleanrenameTmpFile(String fileName, boolean changeFolder, String newFolderExtension) Rename the given file and move to a new folder if required.
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
readResourceFile
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.
-
readResourceFile
Read a text resource file and return the full content as String.- Parameters:
fileLocation- absolute or related name of the file to be read.lineSeparator- Separator string for each line after reading.- Returns:
- the parsed content as string from the given file.
-
renameAllTempFiles
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- ifchangeFolderis 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
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
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.
-
createTempFile
Create a temp file from the file inside the jar.- Parameters:
fileNameInsideJar- Name of the file inside the jar. The file must be in the resource root directory of the jar.- Returns:
- the temp file created from the given file name inside the jar.
-