URL wont open file:\C filepath in Java
<p>I need to open a filename using a URL(java.net.URL) as below:</p>

<blockquote>
  <p>file:/C:/RAdev/Basic/src/test/resources/xml Data/test
  dir/app-config-seed-data.xml</p>
</blockquote>

<p>I've the following java code to read </p>

<pre><code>                fileURL = new File(filePath).toURI().toURL();
                is = fileURL.openStream();
</code></pre>

<p>Since windows can access file:\, even URL should be able to open the same. </p>

<p>Workaround used for now:</p>

<pre><code>            public static final String FILE_URL_PREFIX = "file:";
            if (filePath.contains(FILE_URL_PREFIX)) {
                filePath = filePath.replaceAll("file:/", ""); 
                System.out.println("Modified filepath - " + filePath);
            }
            fileURL = new File(filePath).toURI().toURL();
            is = fileURL.openStream();
</code></pre>

<p>Is the above workaround needed, please let me know if there is another way to reap the benefits of URL accessing. I'm new to URL/URI in java, help is really appreciated.</p>

<p>Thanks. </p>