title: Unable to create File object for a file in Jar
body: <p>I am trying to include a number of text files as resources in my runnable .jar-file. The following code should print the contents of one file:</p>
  
  <pre><code>URI resourceFile = Driver.class.getResource("/etc/inputfile.txt").toURI();
  System.out.println("Opening URI: " + resourceFile.toString());
  File infile = new File(resourceFile);
  
  Scanner sc = new Scanner(infile);
  while (sc.hasNextLine())
      System.out.println(sc.nextLine());
  sc.close();
  </code></pre>
  
  <p>After exporting as a runnable jar, I get the following output when running:</p>
  
  <blockquote>
    <p>Opening URI: rsrc:etc/inputfile.txt<br>
      java.lang.IllegalArgumentException: URI is not hierarchical
              at java.io.File.(File.java:363)</p>
  </blockquote>
  
  <p>The file can be printed without any problems if I use getResourceAsStream, but I'd like to use the File object for other reasons.<br>
  How can I resolve this?</p>
  
  <p>Thanks,<br>
  Martin</p>