private static File renameToBak(File file){
  DateFormat fmt=new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
  if (file.exists() && !file.renameTo(new File(file.getAbsolutePath() + "." + fmt.format(new Date())+ ".bak")))   exit("Failed to rename file '" + file.getPath() + "'.",null);
  return file;
}

private static File renameToBak ( File file ) { DateFormat fmt = new SimpleDateFormat ( "yyyy-MM-dd_HH-mm-ss" ) ; if ( file . exists ( ) && ! file . renameTo ( new File ( file . getAbsolutePath ( ) + "." + fmt . format ( new Date ( ) ) + ".bak" ) ) ) exit ( "Failed to rename file '" + file . getPath ( ) + "'." , null ) ; return file ; }
renames file for backup .
