title: How to make ImageIO read from InputStream :Java
body: <p>I have created executable jar file(using Eclipse) , there are a set of image (.png) files that is to be inculded in the jar. So I have added a source folder with all the images inside <code>/images</code> folder in the project . Code has to access these file to create BufferedImage using <code>ImageIO.read(new File(path);</code></p>
  
  <p>Earlier,
  To get the path I used <code>ClassName.class.getResource(/image/test.png).toURI();</code></p>
  
  <p>On executing jar , it throw error  <em>URI is not hierarchical</em></p>
  
  <p>So now I am using <code>ClassName.class.getResourceAsStream(/image/test.png);</code></p>
  
  <p>But how to make ImageIO read from  Inputstream ?
  I tried cast as follows</p>
  
  <pre><code>InputStreamReader resourceBuff=ClassName.class.getResourceAsStream(/image/test.png);
  ImageIO.read((ImageInputStream) new InputStreamReader(resourceBuff));
  </code></pre>
  
  <p>It throws error <em>InputStreamReader cannot be cast to ImageInputStream</em></p>