I need to rename:
newfolder -> oldfolder;
I need to be sure that in case of exception old folder will be saved.
So I think to do next:
1. rename oldfolder -> tempfolder.
2. rename newfolder -> oldfolder.
3. If previous ok - delete oldfolder.
But I have dubious – may be Apache FileUtils do the same. Or operation of renaming is safe.
What is correct?
Thanks.
If you try to rename a folder to an existing name it will fail. So if you want to replace a folder you should go with the alternative approach you already mentioned.
The logic would be