Class FileHandlingBudget
java.lang.Object
no.ntnu.idatt1002.demo.data.budget.FileHandlingBudget
FileHandling is a class for writing and reading Budgets to and from a file.
- Author:
- andreas
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanMethod for checking if a .budget file is empty.static booleanisNewBudget(String fileDestination) Method for checking if a .budget file is new (no categories) or old (has budget categories).static GeneralBudgetreadGeneralBudgetFromFile(String fileDestination) Method for reading (getting) a Budget from a file.static voidwriteGeneralBudgetToFile(String fileDestination, GeneralBudget generalBudget) Method for writing (adding) a budget to a file.static voidwriteMaxAmountToFile(String fileDestination, String maxAmount) Method for writing the disposable income, the "max amount" of the budget to file.
-
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 checkgeneralBudget- the budget you want to write to a file.- Throws:
IOException- if an input or output exception occurred.
-
isEmpty
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
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
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.
-