Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Byte array to hex char array conversion [duplicate]

Tags:

java

hex

My byte array is look like

 byte[] x = { (byte) 0xff , (byte) 0x80  };

how can i convert it to char array {char[] y } where:-

y[0]='f';
y[1] ='f' and so on
like image 878
Arjun Avatar asked Mar 04 '15 12:03

Arjun


1 Answers

This should help you:

byte[] data = { (byte) 0xff , (byte) 0x80  };
String text = new String(data, "UTF-8");
char[] chars = text.toCharArray();
like image 198
BeWu Avatar answered Nov 06 '22 12:11

BeWu