Class FileHandlingBudgetArchive

java.lang.Object
no.ntnu.idatt1002.demo.data.budget.FileHandlingBudgetArchive

public class FileHandlingBudgetArchive extends Object
Class that handles the reading and writing to the budget archive file, which contains all existing budget projects. New budgets are added to the archive through this class.
Since:
19.04.2023
Author:
Harry Linrui Xu
  • Constructor Details

    • FileHandlingBudgetArchive

      public FileHandlingBudgetArchive()
  • Method Details

    • writeBudgetRegisterToArchive

      public static void writeBudgetRegisterToArchive(BudgetRegister budgetNames, String fileDestination) throws IOException
      Method for writing (adding) a budget register to the archive.
      Parameters:
      budgetNames - The budget register.
      fileDestination - The file destination in resources.
      Throws:
      IOException - if an input or output exception occurred.
    • isBudgetRegisterEmpty

      public static boolean isBudgetRegisterEmpty(String fileDestination) throws IOException
      Checks if the budget register in the archive contains any budget names. In other words, if it is empty.
      Parameters:
      fileDestination - The file destination in resources.
      Returns:
      True, if only "null" is read. Else, returns false.
      Throws:
      IOException - if an input or output exception occurred.
    • readBudgetArchive

      public static BudgetRegister readBudgetArchive(String fileDestination) throws IOException
      Method for reading the budget register from the archive.
      Parameters:
      fileDestination - The file destination in resources.
      Returns:
      The budget register that is read from file.
      Throws:
      IOException - if an input or output exception occurred.