Package org.iam.utils

Class FileUtil

java.lang.Object
org.iam.utils.FileUtil

public class FileUtil extends Object
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 Details

    • FileUtil

      public FileUtil()
  • Method Details

    • getFileNames

      public static List<String> getFileNames(Path directoryPath)
      Returns a sorted list of file names in the given directory.
      Parameters:
      directoryPath - the directory path
      Returns:
      a sorted list of file names
    • createDirectoryIfNotExists

      public static boolean createDirectoryIfNotExists(Path directoryPath)
      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

      public static Path replaceSecondLastLevel(Path inputFoldPath)
      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

      public static String changeToCsvWithTime(String fileName)
      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

      public static String changeToJsonWithFindings(String fileName)
      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

      public static String changeToDot(String fileName)
      Changes the file extension to .dot.
      Parameters:
      fileName - the original file name
      Returns:
      the processed file name with .dot extension