converting byte[] to string

后端 未结 5 1049
[愿得一人]
[愿得一人] 2021-01-13 02:51

I am having a bytearray of byte[] type having the length 17 bytes, i want to convert this to string and want to give this string for another comparison but the output i am g

5条回答
  •  南方客
    南方客 (楼主)
    2021-01-13 03:39

    Use as follows:

    byte[] byteArray = new byte[] {0,127,-1,-2,-54,123,12,110,89,0,0,0,0,0,0,0,0};
    String value = Arrays.toString(byteArray);
    System.out.println(value);
    

    Your output will be

    [0,127,-1,-2,-54,123,12,110,89,0,0,0,0,0,0,0,0]
    

提交回复
热议问题