title: getResource() to a file at runtime
body: <p>I put some <code>.txt</code> files under the <code>src</code> folder (in the <code>resources</code> folder).</p>
  
  <p>But I can't create a valid <code>File</code> at runtime from this resource. </p>
  
  <pre><code>String path = this.getClass().getResource("/resources/file.txt").getFile();
  File file = new File(path);
  
  if (!file.exists()) {
  }
  </code></pre>
  
  <p>I run my program from eclipse. I didn't put in classpath anything.<br>
  I want my text files to be embedded into the <code>.jar</code> file, when I run my app I want to grab those files and copy them into some location.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>if I do <code>InputStream is = getClass().getResourceAsStream("/resources/file.txt");</code></p>
  
  <p>I get the stream!!</p>