Search code examples
javaimageurl

ImageIO.read() returns null


I have a problem regarding the ImageIO.read() function:

URL imageURL = this.getClass().getResource(sheetPath);
spriteSheet = ImageIO.read(imageURL); 

The ImageIO function returns null even though the URL is correct (it leads to a .png file). I've tried to put the getResource() as a parameter for the read function, but that didn't work either. Has anyone encountered a similar problem and maybe found a solution?

Regards

Edit:

sheetPath is "/images/pizzaGirl.png"

imageURL is "file:/Users/Kevin/Dropbox/workspace/PizzaGirl/bin/images/pizzaGirl.png"

images is in the "res" folder which I added to the classpath via the eclipse's run configurations


Solution

  • Okay I tried to replace my path with a different image and it worked. I went back into photoshop, exported my image again and voilà, it works.