How to determine whether a file is stored locally in Java?
<p>I want to check whether a file exists and is a directory:</p>

<pre><code>File file = new File("C:\file.txt");
boolean isValidDir = file.exists() &amp;&amp; file.isDirectory();
</code></pre>

<p>A file can be stored either on the same computer or on a different computer on the network. If the file is stored locally, these methods will return quickly, but if it's stored somewhere else on the network and, say, the network cable is disconnected, it will take a while for these methods to return. Also, if these methods are called from the EDT, the UI will appear to freeze up. (I called these methods from a different thread to avoid this issue.)</p>

<p>I'm wondering if there is a way to tell whether a file, e.g. <code>U:\helloworld\</code>, is stored locally or somewhere else on the network. These methods will still take a while to return in the other thread, but I need to use the result of the line above in the EDT to paint a component accordingly. Any suggestions will be appreciated.</p>
