java.lang.IllegalArgumentException:im == null? [英] java.lang.IllegalArgumentException: im == null?

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

问题描述

我实际上是从 PostgreSQL 获取输入源的.表列类型为 bytea.我想将字节转换回原始图像.

I actually get the input source from PostgreSQL. The table column type is bytea. I want to convert the byte back to original image.

BuffredImage bImageFromConvert = ImageIo.read(new ByteArrayInputStream(rsvalue.getBytes(10)));

ImageIO.write(bImageFromConvert, "jpg", new File("D:\\"+ rsvalue.getString(2) +".jpg"));

错误如下:

Exception in thread "main" java.lang.IllegalArgumentException: im == null!
    at javax.imageio.ImageIO.write(ImageIO.java:1457)
    at javax.imageio.ImageIO.write(ImageIO.java:1521)
    at my.lincdoc.controller.ProposalController.RetrieveProposalForm(ProposalController.java:66)
    at my.lincdoc.common.App.main(App.java:16)

有人可以帮我吗?

推荐答案

ImageIO.read 状态:

如果没有注册的 ImageReader 声称能够读取结果流,则返回 null.

If no registered ImageReader claims to be able to read the resulting stream, null is returned.

如果 bImageFromConvert 为空,您将得到您显示的异常.所以这几乎可以肯定正在发生.您应该查看从 rsvalue.getBytes(10) 返回的数据 - 看看它是否不完整、损坏或类似.一个起点是将其写入文件,然后查看是否可以使用图片查看器打开它.

And if bImageFromConvert is null, you'll get the exception you've shown. So that's almost certainly what's happening. You should look at the data returned from rsvalue.getBytes(10) - see whether it's incomplete, corrupt or something similar. A starting point would be to write it to a file and see whether you can open it using a picture viewer.

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

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