To save the state of the program, we only need to save the task register. We do this by saving the tasks to a CSV-file where each row contains name, description, due date, priority, category, status, start date and finish date.
We use the FileInputStream class and BufferedWriter class from java.io package to read the CSV file when the program is started and re-add all the tasks to the register with all previous information.
When a new task is added we automatically refresh the saved state in the CSV-file using OutputStream, PrintWriter and a private method in the Task class. The method in task class returns each task as a string in csv-format with semicolon as a seperator. To make sure we keep readability in our intellij project, we specify the encoding of the files to UTF-8.
This gives us a simple way of persisting data locally when the program is terminated.