Package main.Utils

Class FileHandler

java.lang.Object
main.Utils.FileHandler

public class FileHandler extends Object
Provide methods to read and write file The class does not have any public constructors and should be used as a static utility class.
Since:
2023-4-13
  • Constructor Details

    • FileHandler

      public FileHandler()
  • Method Details

    • readFile

      public static String[] readFile(String filePath, String check, int col)
      Method to read file
      Parameters:
      filePath - file to read
      check - input to match against
      col - column to check for "check"
      Returns:
      Returns the line as String[] seperated by comma if match found, else return null
    • findFile

      public static boolean findFile(String filePath, String check, int col)
      Method to find if target exist in file
      Parameters:
      filePath - file to check
      check - target to match for
      col - column in csv to find target
      Returns:
      True if found, else return False
    • writeFile

      public static void writeFile(String filepath, String check, int col, String newString)
      Method to write input string to target line
      Parameters:
      filepath - file to write to
      check - target to match against
      col - column in csv to find target
      newString - new string to be written over target line