Welcome back.
So we need to do a couple of things first ven ve start the
we want to load the previously saved tasks from a file
and then we could be exit the app.
We want to save the tasks as they are in that file.
So let's start by writing to file first.
So we will save the task data to a file and let me go
to the top off our controller and I will create just a string
which is called fire, but and you can use anybody that
you like.
Hunt Simply going to use it are not be X t.
This is refile.
Uh, but you can use an absolute but if you want, and we
will create an instance off this file.
So let's create a fire.
And this will come from charlotte dot io.
So of any click on it, it will automatically import Salvador
tired file.
So this is our data file, and we can create a an instance
if it but new file and Facebook okay.
And when we exit the app at that time, we want to reiterate
over how were ah tusks and saved them.
So let me go to exit program.
Here we go.
And before we actually exit, Viva Ah, get the tasks that PM
So So let's create a list off spring elements and no need
to import the list from Java or Digital has felt.
So let's press old enter and it will be important.
There we go.
Correct.
So we cleared in lest And let's call it government risks
in the past list.
Beaver get idols so that the list No, we want to it rate over
the current tasks and write each task in a new line in our
file. So let's create a file writer discolored writer,
And this is a new file Reiter for the file part, it is simply
did not be X t and, well, it right over be, uh, good in tasks.
So let's take a look at each text worker in tasks and let's
upend all be, uh, mosques in new line in writer.
But right, once we had been vigorous, even those three vector
All right, this is because we need to handle for ah,
a potential exception.
So it says here that unhand Aled exception Java, Dodi Dodi
exception.
So either you can add the ah Add the exception.
Do your method.
Signature are you can use Ah, surround discord with try
and catch.
So what?
The options are fine.
Let's go to try and catch Sonam and be okay.
Create the file writer, which can potentially throw
and I exception this around that part of the court
in in a try and catch block in the same thing is true
for the writer dark clothes and writer dork, right methods.
So we should actually just copy them and based them here
in the trade block.
And that solves over problem.
All right, so now, in your project, right now in the Data
Analytics to find does not actually exist.
But this name that's evil.
This time, when be exit, it will be created.
Okay, Philip me and get rid of this line.
Ah, it's it automatically at it.
Maybe it didn't do that for you.
That's okay.
And instead, she it our final writer in the try block itself
Difficult.
So let's save our changes and run the application.
No, I had a few tasks.
No, When we exit, if everything works, OK, then you will see
a data about the extra file is populated.
And if you open it, you will see that it has the dude USC's
grid. So we have successfully saved our data.
But now then our application loads.
We also need a V two load the previously saved data, which is
from this data about the extra file.
Let's do that in the next task.