How to print the data in byte array as characters?

后端 未结 6 1120
广开言路
广开言路 2020-12-07 17:18

In my byte array I have the hash values of a message which consists of some negative values and also positive values. Positive values are being printed easily by us

6条回答
  •  一整个雨季
    2020-12-07 17:57

    How about Arrays.toString(byteArray)?

    Here's some compilable code:

    byte[] byteArray = new byte[] { -1, -128, 1, 127 };
    System.out.println(Arrays.toString(byteArray));
    

    Output:

    [-1, -128, 1, 127]
    

    Why re-invent the wheel...

提交回复
热议问题