samedi 21 février 2015

How to convert int array to hex string

I want to convert an int array to a hex string. I am unsure if I am doing this correctly.


I create an int[] in another class and get it with via msg.obj. I am getting some values in Hex but am unsure if they are correct.



int[] readBuf = (int[]) msg.obj; //int array is in another class
StringBuffer output=new StringBuffer();
for (int a:readBuf) {
int val1 = a & 0xff;
output.append(Integer.toHexString(val1));
}
dataView.setText(output);

Aucun commentaire:

Enregistrer un commentaire