Okay, so I've been trying to load a BufferedImage using this code:
URL url = this.getClass().getResource("test.png"); BufferedImage img = (BufferedImage) Toolkit.getDefaultToolkit().getImage(url);
This gives me a type cast error when I run it though, so how do I properly load a BufferedImage?
Use ImageIO.read() instead:
ImageIO.read()
BufferedImage img = ImageIO.read(url);
2.1m questions
2.1m answers
60 comments
57.0k users