java.lang.IllegalArgumentException: input == null! Solution

Recently I was compiling a Javagame and encountered the following problems when processing pictures:

Full error message

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: input == null!
	at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1356)
	at ImageIOTest.main.<init>(main.java:23)

code segment

BufferedImage img = ImageIO.read(getClass().getResourceAsStream(FILENAME));

Solution

Many searches on the Internet say that the path of the picture is wrong, but I have checked the path of the picture 555 n 555n5 5 5 n times, no problem
Insert picture description here
so? No way?
In fact, it's right to change it like this:

BufferedImage img = ImageIO.read(new File(FILENAME));

Guess you like

Origin blog.csdn.net/write_1m_lines/article/details/105182291