public void makeBackupFile(String name){
  File file=findFile(name);
  if (file == null) {
    log.info("No " + name + " file to backup");
  }
 else   if (file.canWrite()) {
    String backupName=backupFileName(file.getAbsolutePath());
    File backupFile=findFile(backupName);
    if (backupFile != null) {
      if (backupFile.delete()) {
        log.debug("deleted backup file " + backupName);
      }
    }
    if (file.renameTo(new File(backupName))) {
      log.debug("created new backup file " + backupName);
    }
 else {
      log.error("could not create backup file " + backupName);
    }
  }
}

public void makeBackupFile ( String name ) { File file = findFile ( name ) ; if ( file == null ) { log . info ( "No " + name + " file to backup" ) ; } else if ( file . canWrite ( ) ) { String backupName = backupFileName ( file . getAbsolutePath ( ) ) ; File backupFile = findFile ( backupName ) ; if ( backupFile != null ) { if ( backupFile . delete ( ) ) { log . debug ( "deleted backup file " + backupName ) ; } } if ( file . renameTo ( new File ( backupName ) ) ) { log . debug ( "created new backup file " + backupName ) ; } else { log . error ( "could not create backup file " + backupName ) ; } } }
move original file to a backup . use this before writing out a new version of the file .
