Package org.iam.utils
Class FileUtil
java.lang.Object
org.iam.utils.FileUtil
Utility class for file and directory operations.
Provides methods for listing files, creating directories, and generating output file names.
- Since:
- 2025-02-28
- Author:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringchangeToCsvWithTime(String fileName) Changes the file extension to .csv and appends "_time" to the base name.static StringchangeToDot(String fileName) Changes the file extension to .dot.static StringchangeToJsonWithFindings(String fileName) Changes the file extension to .json and appends "_result" to the base name.static booleancreateDirectoryIfNotExists(Path directoryPath) Creates the directory if it does not exist.getFileNames(Path directoryPath) Returns a sorted list of file names in the given directory.static PathreplaceSecondLastLevel(Path inputFoldPath) Replaces the second last level of the input path with "results".
-
Constructor Details
-
FileUtil
public FileUtil()
-
-
Method Details
-
getFileNames
Returns a sorted list of file names in the given directory.- Parameters:
directoryPath- the directory path- Returns:
- a sorted list of file names
-
createDirectoryIfNotExists
Creates the directory if it does not exist.- Parameters:
directoryPath- the directory path- Returns:
- true if the directory exists or was created successfully, false otherwise
-
replaceSecondLastLevel
Replaces the second last level of the input path with "results".- Parameters:
inputFoldPath- the input path- Returns:
- the new path with the second last level replaced
-
changeToCsvWithTime
Changes the file extension to .csv and appends "_time" to the base name.- Parameters:
fileName- the original file name- Returns:
- the processed file name with .csv extension and "_time" appended
-
changeToJsonWithFindings
Changes the file extension to .json and appends "_result" to the base name.- Parameters:
fileName- the original file name- Returns:
- the processed file name with .json extension and "_result" appended
-
changeToDot
Changes the file extension to .dot.- Parameters:
fileName- the original file name- Returns:
- the processed file name with .dot extension
-