private boolean renameOverwrite ( String oldname , String newname ) { boolean deleted = delete ( newname ) ; if ( exists ( oldname ) ) { File file = new File ( oldname ) ; return file . renameTo ( new File ( newname ) ) ; } return deleted ; }
Rename the file with oldname to newname . If a file with newname already exists it is deleted before the renaming operation proceeds .