最近在编一个Java
游戏,处理图片时遇到如下问题:
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)
BufferedImage img = ImageIO.read(getClass().getResourceAsStream(FILENAME));
在网上搜了好多都是说图片路径不对,但是我已经把图片路径检查了遍了,还没发现问题
so?没路了?
其实改成这样就对了:
BufferedImage img = ImageIO.read(new File(FILENAME));