title: I get an "Unknown Source" exception uploading a Buffered Image
body: <p>To upload an Image I use this code</p>
  
  <pre><code>public static BufferedImage getSprite(String file,Object obj)
  {
      BufferedImage sprite = null;
      try
      {
          sprite=ImageIO.read(obj.getClass().getResource(file));
      }
      catch(Exception e)
      {
          System.out.println("File doesn't exist");
      }
      return sprite;
  }
  </code></pre>
  
  <p>And then</p>
  
  <pre><code>public class Grass
  </code></pre>
  
  <p>{</p>
  
  <pre><code>BufferedImage grass=SpriteHandler.getSprite("/Resources/grass_tile.gif",this);
  
  
  
  public void render(Graphics g)
  {
  
      g.drawImage(grass, 0, 0, null);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>When I add this to the Main class with Grass grass=new Grass()
  It catches<code>Exception in thread "Thread-2" java.lang.NullPointerException
      at Game.render(Game.java:99)
      at Game.run(Game.java:75)
      at java.lang.Thread.run(Unknown Source)</code></p>
  
  <p>I tried everything, it works only if I put the "getSprite" method inside "render(Graphics g)", but in this way the program slows down </p>