将InputStream转换为BufferedImage将返回null

时间:2012-10-04 14:48:40

标签: java blob

我正在编写一个代码来从数据库中检索多个“blob”图像并将它们连接在一起, 下面是代码

ResultSet images = pst.executeQuery();
byte[] imageData = null;
Blob blob = null;
int blobLength = 0;
List<BufferedImage> list = new LinkedList();

while (images.next()) {                                 
    blob = ((OracleResultSet) images).getBLOB(2);
    blobLength = (int) blob.length();
    imageData = blob.getBytes(1, blobLength);   
    list.add(ImageIO.read(new ByteArrayInputStream(imageData)));
}

问题是列表总是为null, 虽然变量'imageData'包含图像(我嘲笑它)。 这意味着,java无法将ByteArrayInputStream转换为BufferedImage,为什么?? !!

0 个答案:

没有答案