public static void moveFile(File srcFile,File destFile) throws IOException {
  if (srcFile == null) {
    throw new NullPointerException("Source must not be null");
  }
  if (destFile == null) {
    throw new NullPointerException("Destination must not be null");
  }
  if (!srcFile.exists()) {
    throw new FileNotFoundException("Source '" + srcFile + "' does not exist");
  }
  if (srcFile.isDirectory()) {
    throw new IOException("Source '" + srcFile + "' is a directory");
  }
  if (destFile.exists()) {
    throw new FileExistsException("Destination '" + destFile + "' already exists");
  }
  if (destFile.isDirectory()) {
    throw new IOException("Destination '" + destFile + "' is a directory");
  }
  boolean rename=srcFile.renameTo(destFile);
  if (!rename) {
    copyFile(srcFile,destFile);
    if (!srcFile.delete()) {
      FileUtils.deleteQuietly(destFile);
      throw new IOException("Failed to delete original file '" + srcFile + "' after copy to '"+ destFile+ "'");
    }
  }
}

public static void moveFile ( File srcFile , File destFile ) throws IOException { if ( srcFile == null ) { throw new NullPointerException ( "Source must not be null" ) ; } if ( destFile == null ) { throw new NullPointerException ( "Destination must not be null" ) ; } if ( ! srcFile . exists ( ) ) { throw new FileNotFoundException ( "Source '" + srcFile + "' does not exist" ) ; } if ( srcFile . isDirectory ( ) ) { throw new IOException ( "Source '" + srcFile + "' is a directory" ) ; } if ( destFile . exists ( ) ) { throw new FileExistsException ( "Destination '" + destFile + "' already exists" ) ; } if ( destFile . isDirectory ( ) ) { throw new IOException ( "Destination '" + destFile + "' is a directory" ) ; } boolean rename = srcFile . renameTo ( destFile ) ; if ( ! rename ) { copyFile ( srcFile , destFile ) ; if ( ! srcFile . delete ( ) ) { FileUtils . deleteQuietly ( destFile ) ; throw new IOException ( "Failed to delete original file '" + srcFile + "' after copy to '" + destFile + "'" ) ; } } }
moves a file . < p > when the destination file is on another file system , do a " copy and delete " .
