title: renameTo() not working
body: <p>I need to rename a file by replacing <code>-</code> with <code>_</code> in the file name. </p>
  
  <p>Suppose if a file name is <code>ab-9.xml</code>, it should be <code>ab_9.xml</code>. </p>
  
  <p><code>renameTo()</code> is not working for me. Is there any other way to do that? Here is my code:</p>
  
  <pre><code>File replaceCheracter(File file) {
          File oldPath = new File(file.getPath())
          String filePath = file.getPath()
          if(filePath.contains("-")){
              String newFilePath = filePath.replace("-", "_")
              if(oldPath.renameTo(newFilePath)) {
                  System.out.println("renamed");
               } else {
                  System.out.println("Error");
               }
          }
          return oldPath
      }
  </code></pre>