问题描述:

I use this code to convert it.

ByteArrayOutputStream simpan = new ByteArrayOutputStream();

ImageIO.write((BufferedImage)image, "JPG", simpan);

But when I try to show the simpan.toString, the result was this.

When I convert it to PNG like via

ImageIO.write((BufferedImage)image, "PNG", simpan);

I got this.

Is this condition correct? And when I send those bytes to an android phone via socket, no image appeared on the phone.

网友答案:

You need to write the content of the ByteArrayOutputStream to a file with the proper extension, then open it with your file explorer. What you're doing right now is outputing the bytes of the JPEG or PNG images in a text console.

相关阅读:
Top