title: Java: Get URI from FilePath
body: <p>I've little knowledge of Java. I need to construct a string representation of an URI from <code>FilePath(String)</code> on windows. Sometimes the <code>inputFilePath</code> I get is: <code>file:/C:/a.txt</code> and sometimes it is: <code>C:/a.txt</code>. Right now, what I'm doing is:</p>
  
  <pre><code>new File(inputFilePath).toURI().toURL().toExternalForm()
  </code></pre>
  
  <p>The above works fine for paths, which are not prefixed with <code>file:/</code>, but for paths prefixed with <code>file:/</code>, the .<code>toURI</code> method is converting it to a invalid URI, by appending value of current dir, and hence the path becomes invalid.</p>
  
  <p>Please help me out by suggesting a correct way to get the proper URI for both kind of paths.</p>