IllegalArgumentException输入== null [英] IllegalArgumentException Input == null

查看:228
本文介绍了IllegalArgumentException输入== null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将图像读作 InputStream 。但由于某种原因,我总是得到 IllegalArugmentException

I am trying to read an Image as an InputStream. But for some reason I always get an IllegalArugmentException.

这是我的代码:

BufferedImage i = null; 
i = ImageIO.read(getClass().getResourceAsStream("/res/graphics" + path));


推荐答案

原因:

您的资源评估为 null ,这就是异常

Your resource evaluates to null and that is why the exception

API doc


抛出:
IllegalArgumentException - 如果输入为 null

解决方案:

如果 res / graphics /无论在root的classpath中然后它将返回not null

If res/graphics/whatever is in classpath at root then it will return not null

这篇关于IllegalArgumentException输入== null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆