// Get JAFFE database from http://www.kasrl.org/jaffe_info.html
// Extract pics in folder named "jaffe"
// package image_test;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class svq {

    public static void main(String[] args) {
        // read image
        BufferedImage input = null;
        try {
            input = ImageIO.read(new File("jaffe/KA.AN1.39.tiff.bmp"));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        // to byte array
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ImageIO.write( input, "bmp", baos );
            baos.flush();
        } catch (IOException e) {

        }
        byte[] bytearray = baos.toByteArray();

        // to BufferedImage
        ByteArrayInputStream bais = new ByteArrayInputStream(bytearray);
        BufferedImage output = null;
        try {
            output = ImageIO.read(bais);
            bais.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

        System.out.println("Done!");
    }
}
@@ -1182,32 +1182,221 @@
 (e);%0A        %7D%0A%0A
+        // save result%0A        try %7B%0A            ImageIO.write(output, %22BMP%22, new File(%22test.bmp%22));%0A        %7D catch (IOException e) %7B%0A            throw new RuntimeException(e);%0A        %7D%0A%0A
         System.o

Save buffered image as bmp