title: Java - Reading in Image (IIOException: Can't Create an ImageInputStream)
body: <p>I'm writing a simple game using a data driven design in which I read in the images for the various elements of the game. As such I've written a parser to read-in the files, confirm that they're an acceptable image format, and create a new Sprite (class I've written) using the files.</p>
  
  <p>I read in the files using ImageIO.read() as seen in the example below.</p>
  
  <pre><code>toAdd = new Sprite(ImageIO.read(targetFile));
  </code></pre>
  
  <p>The stack trace for the exception is as follows:</p>
  
  <pre><code>javax.imageio.IIOException: Can't create an ImageInputStream!
      at javax.imageio.ImageIO.read(ImageIO.java:1280)
      at edu.moravian.utilities.dataParsers.GraphicsDataParser.readInSprites(GraphicsDataParser.java:53)
  </code></pre>
  
  <p>I've got no idea what's causing this. The application isn't multi-threaded, the images are in the correct directory and are confirmed to exist, and I have the permissions necessary to access the images.</p>
  
  <p>What might I be missing?</p>