/** The file intermediate has the new file contents. We want to move them to the current file. renameTo doesn't have a powerful enough semantics, so we anticipate failure and attempt to bypass it ... <p> If the rename works, that's fine. If it fails, we delete the old file if it exists, and try again. */ protected void updateFrom( File targetName, File intermediate ) { if (intermediate.renameTo( targetName ) == false) { if (targetName.exists()) mustDelete( targetName ); mustRename( intermediate, targetName ); } }