最近在编一个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));
解决方法
在网上搜了好多都是说图片路径不对,但是我已经把图片路径检查了\(555n\)遍了,还没发现问题
so?没路了?
其实改成这样就对了:
BufferedImage img = ImageIO.read(new File(FILENAME));
标签:lang,ImageIO,read,IllegalArgumentException,input,java,null
From: https://www.cnblogs.com/stanleys/p/18403420/java-image-iaein-solve