Class FileHandlingBudget

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

public class FileHandlingBudget extends Object
FileHandling is a class for writing and reading Budgets to and from a file.
Author:
andreas
  • Constructor Details

    • FileHandlingBudget

      public FileHandlingBudget()
  • Method Details

    • writeGeneralBudgetToFile

      public static void writeGeneralBudgetToFile(String fileDestination, GeneralBudget generalBudget) throws IOException
      Method for writing (adding) a budget to a file.
      Parameters:
      fileDestination - the path and name of the file you want to check
      generalBudget - the budget you want to write to a file.
      Throws:
      IOException - if an input or output exception occurred.
    • isEmpty

      public static boolean isEmpty(String fileDestination) throws IOException
      Method for checking if a .budget file is empty.
      Parameters:
      fileDestination - the path and name of the file you want to check
      Returns:
      true or false depending on if file is empty.
      Throws:
      IOException - if an input or output exception occurred.
    • isNewBudget

      public static boolean isNewBudget(String fileDestination) throws IOException
      Method for checking if a .budget file is new (no categories) or old (has budget categories).
      Parameters:
      fileDestination - The path and name of the file
      Returns:
      True, if the budget is new. Else, returns false
      Throws:
      IOException - if an input or output exception occurred.
    • writeMaxAmountToFile

      public static void writeMaxAmountToFile(String fileDestination, String maxAmount) throws IOException
      Method for writing the disposable income, the "max amount" of the budget to file.
      Parameters:
      fileDestination - The file destination that max amount will be written into.
      maxAmount - The disposable income of the budget.
      Throws:
      IOException - if an input or output exception occurred.
    • readGeneralBudgetFromFile

      public static GeneralBudget readGeneralBudgetFromFile(String fileDestination) throws IOException
      Method for reading (getting) a Budget from a file.
      Parameters:
      fileDestination - the name of the file you want to read from.
      Returns:
      the GeneralBudget from the file.
      Throws:
      IOException - if an input or output exception occurred.