title: accessing a local file (Java URL)
body: <p>I'm trying to open a stream to a file on my PC and I'm trying to do it via URL (I know,It's just for leraning purposes)
  this is what I'm doing:</p>
  
  <pre><code>import java.io.IOException;
  import java.io.InputStream;
  import java.net.MalformedURLException;
  import java.net.SocketTimeoutException;
  import java.net.URL;
  import java.net.URLConnection;
  
  public class URLTyper {
  
      public static void main(String[] args) {
          InputStream in=null;
          try {
              URL url=new URL("file://127.0.0.1/c:/haxlogs.txt");
  //          in=url.openStream();
              URLConnection conn=url.openConnection();
              conn.connect();
              in=conn.getInputStream();
              while (true) {
                  int read=in.read();
                  if (read==-1) break;
                  System.out.write(read);
              }
          }
          catch (SocketTimeoutException e){
              System.out.println("timed out");
          }
          catch (MalformedURLException e) {
              System.out.println("URL not valid");
          }
  
          catch (IOException e) {
              System.out.println("unable to get data");
          }
      }
  
  }
  </code></pre>
  
  <p>It exits throwing an IOException ("unable to access data").. why is it not working? shouldn't it get to the file like an ordinary InputStream?
  thanks</p>