title: Why opening a file input stream on file packaged in jar via getResource does't work?
body: <pre><code>InputStream inputStream = new FileInputStream(new File(this.getClass().getResource("/example.txt").getFile()))
  </code></pre>
  
  <p>This method will cause error like as "/.../.../...jar!/example.txt (no such file or directory)" .</p>
  
  <pre><code>InputStream inputStream = getClass().getResourceAsStream("/example.txt")
  </code></pre>
  
  <p>This method will run right.</p>
  
  <p>So, what's the difference between those two methods? And why the first method does't work?</p>