I tried to create image from BLOB. I try following code but it is not working at step:
ImageIO.write(image, "JPG", iio);)
image is null. Please give me any suggestion.
byte[] imgData = null;
if (rs.next ())
{
Blob img = rs.getBlob(1);
imgData = img.getBytes(1,(int)img.length());
File f1 = new File(fillFilePath); //fillFilePath = path where image want to store
BufferedImage image = ImageIO.read(new ByteArrayInputStream(imgData));
ImageOutputStream iio = ImageIO.createImageOutputStream(f1);
ImageIO.write(image, "JPG", iio);
}
How to create image from BLOB using ImageIO?
From the JavaDoc on
ImageIO.read(InputStream):It seems your blob doesn’t represent an image format that
ImageIOis able to understand. What format does the image stored in the blob have?