栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

异常IllegalArgumentException: input == null以及imageio.IIOException: Can‘t read input file的解决方案

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

异常IllegalArgumentException: input == null以及imageio.IIOException: Can‘t read input file的解决方案

问题描述

在项目中导入图片出错


原因分析:

在API文档中找到illegalArgumentException的父类是RuntimeException所以属于运行异常。

分析是哪一种问题:

非法数据异常无法通过一个标识或者基本扩展转换将转换为基本数组的指定类型位置描述为空指定对象参数不是数组


解决方案:

猜测是图片路径出现问题

 如图所示:

    红框中第一个输出结果为   input ==  null! 是没有找到输入值红框中第二个输出结果是    Can’t read input file!    是读取图片文件位置报错
1.图片文件引入错误 java.lang.IllegalArgumentException: input == null!
    注意文件名与路径中文件名大小写是否符合可以使用相对路径或绝对路径尝试代码语句错误

hero1 = ImageIO.read(ShootGame.class.getResource("路径"));

 替换后

BufferedImage image = ImageIO.read(getClass().getResource(file));

2.读取图片位置报错 javax.imageio.IIOException: Can’t read input file!

image = ImageIO.read(ShootGame.class.getResource());

替换后

BufferedImage image=ImageIO.read(new File(fille));


 结论:注意路径问题和图片名称
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/759859.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号