Hi.
I want to create a temporary file which backs up all the data stored in the main file my program uses when my program launches incase of any IOExceptions which may occur when writing the array of data to the main file.
I know there's a createTempFile() method in File, but im not sure how to get it to do what I want.
Ideally when the program starts a temp file should be created containing all the data contained in the main file.
If no errors occur during program execution it should be deleted at the end. (using deleteOnExit() method).
However, should an Exception occur, I'd like it to be renamed to the main file's pathname (therefor replacing it).
If anyone has any idea how this would be acheived, I'd be VERY grateful!!
All comments welcome!
Thanks very much,
Oxy
we are all of us living in the gutter.
But some of us are looking at the stars.
I want to create a temporary file which backs up all the data stored in the main file my program uses when my program launches incase of any IOExceptions which may occur when writing the array of data to the main file.
I know there's a createTempFile() method in File, but im not sure how to get it to do what I want.
Ideally when the program starts a temp file should be created containing all the data contained in the main file.
If no errors occur during program execution it should be deleted at the end. (using deleteOnExit() method).
However, should an Exception occur, I'd like it to be renamed to the main file's pathname (therefor replacing it).
If anyone has any idea how this would be acheived, I'd be VERY grateful!!
All comments welcome!
Thanks very much,
Oxy
we are all of us living in the gutter.
But some of us are looking at the stars.