public static void rename(String from,String to){
  Process p=null;
  Thread std=null;
  try {
    Runtime runTime=Runtime.getRuntime();
    log.debug("Execute runtime");
    if (File.separatorChar == '\\') {
      p=runTime.exec("CMD /D /C \"REN " + from + ' '+ to+ "\"");
    }
 else {
      p=runTime.exec("mv -f " + from + ' '+ to);
    }
    std=stdOut(p);
    while (std.isAlive()) {
      try {
        Thread.sleep(250);
      }
 catch (      Exception e) {
      }
    }
    log.debug("Process threads wait exited");
  }
 catch (  Exception e) {
    log.error("Error running delete script",e);
  }
 finally {
    if (null != p) {
      log.debug("Destroying process");
      p.destroy();
      p=null;
      std=null;
    }
  }
}

public static void rename ( String from , String to ) { Process p = null ; Thread std = null ; try { Runtime runTime = Runtime . getRuntime ( ) ; log . debug ( "Execute runtime" ) ; if ( File . separatorChar == '\\' ) { p = runTime . exec ( "CMD /D /C \"REN " + from + ' ' + to + "\"" ) ; } else { p = runTime . exec ( "mv -f " + from + ' ' + to ) ; } std = stdOut ( p ) ; while ( std . isAlive ( ) ) { try { Thread . sleep ( 250 ) ; } catch ( Exception e ) { } } log . debug ( "Process threads wait exited" ) ; } catch ( Exception e ) { log . error ( "Error running delete script" , e ) ; } finally { if ( null != p ) { log . debug ( "Destroying process" ) ; p . destroy ( ) ; p = null ; std = null ; } } }
rename a file natively ; using ren on windows and mv on * nix .
