java.lang.IllegalArgumentException:im == null? [英] 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)
任何人都可以帮助我吗?
Anyone can help me ?
推荐答案
ImageIO.read
状态:
如果没有注册的ImageReader声称能够读取结果流,则返回null 。
If no registered ImageReader claims to be able to read the resulting stream, null is returned.
如果 bImageFromConvert
为null,则会得到异常已经显示。因此,几乎可以肯定这是正在发生的事情。您应该查看从 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屋!