0

Let us assume that I have a byte[], I want to convert it to String and then back to byte[].

byte[] b = {-23, -38, 62, 22, -25, -23, 46, 106, -38, 13, -2, -46, 6, -110, 25, -82};   
System.out.println(Arrays.toString(new String(b).getBytes()));

I receive other byte[]:

[-17, -65, -67, -17, -65, -67, 62, 22, -17, -65, -67, -17, -65, -67, 46, 106, -17, -65, -67, 13, -17, -65, -67, -17, -65, -67, 6, -17, -65, -67, 25, -17, -65, -67]

Why is this happening? I can get an initial byte[] thus?

Ousmane D.
  • 54,915
  • 8
  • 91
  • 126
MrHoj
  • 13
  • 2

0 Answers0