Converting byte array to String (Java)

前端 未结 7 955
不知归路
不知归路 2020-11-28 06:29

I\'m writing a web application in Google app Engine. It allows people to basically edit html code that gets stored as an .html file in the blobstore.

I\

相关标签:
7条回答
  • 2020-11-28 07:11

    I suggest Arrays.toString(byte_array);

    It depends on your purpose. For example, I wanted to save a byte array exactly like the format you can see at time of debug that is something like this : [1, 2, 3] If you want to save exactly same value without converting the bytes to character format, Arrays.toString (byte_array) does this,. But if you want to save characters instead of bytes, you should use String s = new String(byte_array). In this case, s is equal to equivalent of [1, 2, 3] in format of character.

    0 讨论(0)
提交回复
热议问题