code: public static void deleteDstAndRename(File srcFile, File dstFile) throws IOException
     {
        if (dstFile.exists())
        {
           if (!dstFile.delete())
           {
              throw new IOException("Cannot delete " + dstFile);
           }
        }
  
        renameFile(srcFile, dstFile);
     }
docs: Rename file. Trying to remove destination first.
  If file can't be renamed in standard way the coping
  data will be used instead.
  
  @param srcFile
  source file
  @param dstFile
  destination file
  @throws IOException
  if any exception occurred