I converted an image file to byte array and then save as a BLOB in database but when i retrieve the saved byte array from database and converted it back to the image file, the image file is not showing.
converted image file to byte array like this:
File imageFile = new File("image.jpg");
byte[] byteArrayOfImageFile = new byte[(int)imageFile.length()];
FileInputStream fileInputStream = new FileInputStream(imageFile);
fileInputStream.read(byteArrayOfImageFile);
fileInputStream.close();
converted byte array to image file like this:
FileOutputStream fos = new FileOutputStream("image.jpg);
try {
fos.write(byteArrayOfImageFile);
} finally {
fos.close();
}