Convert byte array (byte[]) to Image in Java

后端 未结 2 1464
难免孤独
难免孤独 2020-12-21 00:41

I have a byte[] that I want to convert to an Image and display the image in a label. The byte[] is of a jpeg 2000 format. I have tried the code below but it ret

2条回答
  •  生来不讨喜
    2020-12-21 01:36

    ServletOutputStream out = response.getOutputStream();
    out.write(user.getBytes());
    

    The above is how its worked for me in the past where user has a profile picture simply stored in a byte array. The servlet realizes this and outputs the image.

提交回复
热议问题