Donate : Link
Medium Blog : Link
Applications : Link
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* @author code_factory
*/
public class BufferedImageToByte {
public static void main(String args[]) {
try {
BufferedImage image = ImageIO.read(new File("R:\\code_factory\\image.jpg"));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "jpg", baos);
baos.flush();
byte[] byteArray = baos.toByteArray();
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

