Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating a TempFile???

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top