Generate URL for File
<p>The default output of <code>File.toURL()</code> is</p>

<pre><code>file:/c:/foo/bar
</code></pre>

<p>These don't appear to work on windows, and need to be changed to</p>

<pre><code>file:///c:/foo/bar
</code></pre>

<p>Does the format</p>

<pre><code>file:/foo/bar
</code></pre>

<p>work correctly on Unix (I don't have a Unix machine to test on)? Is there a library that can take care of generating a URL from a File that is in the correct format for the current environment?</p>

<p>I've considered using a regex to fix the problem, something like:</p>

<pre><code>fileUrl.replaceFirst("^file:/", "file:///")
</code></pre>

<p>However, this isn't quite right, because it will convert a correct URL like:</p>

<pre><code>file:///c:/foo/bar
</code></pre>

<p>to:</p>

<pre><code>file://///c:/foo/bar
</code></pre>

<p><strong>Update</strong></p>

<p>I'm using Java 1.4 and in this version <code>File.toURL()</code> is not deprecated and both <code>File.toURL().toString()</code> and <code>File.toURI().toString()</code> generate the same (incorrect) URL on windows</p>
