public static boolean rename(File fromFile,File toFile){
  logger.log(Level.CONFIG,"Renaming From:" + fromFile.getAbsolutePath() + " to "+ toFile.getAbsolutePath());
  if (toFile.exists()) {
    logger.log(Level.SEVERE,"Destination File:" + toFile + " already exists");
    return false;
  }
  final boolean result=fromFile.renameTo(toFile);
  if (!result) {
    if (copy(fromFile,toFile)) {
      boolean deleteResult=fromFile.delete();
      if (!deleteResult) {
        logger.log(Level.SEVERE,"Unable to delete File:" + fromFile);
        toFile.delete();
        return false;
      }
      return true;
    }
 else {
      return false;
    }
  }
  return true;
}

public static boolean rename ( File fromFile , File toFile ) { logger . log ( Level . CONFIG , "Renaming From:" + fromFile . getAbsolutePath ( ) + " to " + toFile . getAbsolutePath ( ) ) ; if ( toFile . exists ( ) ) { logger . log ( Level . SEVERE , "Destination File:" + toFile + " already exists" ) ; return false ; } final boolean result = fromFile . renameTo ( toFile ) ; if ( ! result ) { if ( copy ( fromFile , toFile ) ) { boolean deleteResult = fromFile . delete ( ) ; if ( ! deleteResult ) { logger . log ( Level . SEVERE , "Unable to delete File:" + fromFile ) ; toFile . delete ( ) ; return false ; } return true ; } else { return false ; } } return true ; }
rename file , and if normal rename fails , try copy and delete instead
