title: get File from JAR
body: <p>I'm using Spring's <a href="http://static.springsource.org/spring/docs/2.5.4/api/org/springframework/core/io/Resource.html" rel="nofollow noreferrer">Resource</a> abstraction to work with resources (files) in the filesystem. One of the resources is a file inside a JAR file. According to the following code, it appears the reference is valid</p>
  
  <pre><code>ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
  
  // The path to the resource from the root of the JAR file
  Resource fileInJar = resourcePatternResolver.getResources("/META-INF/foo/file.txt");
  
  templateResource.exists(); // returns true
  templateResource.isReadable();  // returns true
  </code></pre>
  
  <p>At this point, all is well, but then when I try to convert the <code>Resource</code> to a <code>File</code></p>
  
  <pre><code>templateResource.getFile();
  </code></pre>
  
  <p>I get the exception</p>
  
  <pre><code>java.io.FileNotFoundException: class path resource [META-INF/foo/file.txt] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/D:/m2repo/uic-3.2.6-0.jar!/META-INF/foo/file.txt        
  at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:198)
  at org.springframework.core.io.ClassPathResource.getFile(ClassPathResource.java:174)
  </code></pre>
  
  <p>What is the correct way to get a <code>File</code> reference to a <code>Resource</code> that exists inside a JAR file?</p>