Class FileHandling
java.lang.Object
no.ntnu.idatt1002.demo.data.economics.FileHandling
FileHandling is a class for writing and reading ItemRegister-objects to and from a file.
- Author:
- andreas
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Method for checking if a .register file is empty.static ExpenseRegister
readExpenseRegisterFromFile
(String fileDestination) Method for reading (getting) an ExpenseRegister from a file.static IncomeRegister
readIncomeRegisterFromFile
(String fileDestination) Method for reading (getting) an IncomeRegister from a file.static <T extends Item>
voidwriteItemRegisterToFile
(ItemRegister<T> itemRegister, String fileDestination) Method for writing (adding) an ItemRegister to a file.
-
Constructor Details
-
FileHandling
public FileHandling()
-
-
Method Details
-
writeItemRegisterToFile
public static <T extends Item> void writeItemRegisterToFile(ItemRegister<T> itemRegister, String fileDestination) throws IOException Method for writing (adding) an ItemRegister to a file.- Type Parameters:
T
- Subclass of item, either expense or income.- Parameters:
itemRegister
- the ItemRegister you want to write to a file.fileDestination
- the path and name of the file you want to check- Throws:
IOException
- if an input or output exception occurred.
-
isEmpty
Method for checking if a .register 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.
-
readIncomeRegisterFromFile
Method for reading (getting) an IncomeRegister from a file.- Parameters:
fileDestination
- the name of the file you want to read from.- Returns:
- the IncomeRegister from the file.
- Throws:
IOException
- if an input or output exception occurred.
-
readExpenseRegisterFromFile
public static ExpenseRegister readExpenseRegisterFromFile(String fileDestination) throws IOException Method for reading (getting) an ExpenseRegister from a file.- Parameters:
fileDestination
- the name of the file you want to read from.- Returns:
- the ExpenseRegister from the file.
- Throws:
IOException
- if an input or output exception occurred
-