Convert byte array to decimal

I have a byte array, and I want to do some manipulations based on the data that I have in this array. The contents of the byte array are in hexadecimal format.

byte[] signal = message.getFieldValue( "_Decoder Message" ).data(); 

This gives me an array of bytes with the following contents

 [ff ff 11 ff ff 82 05 00 13 00 d7 00 fc dc 03 04 00 00 01 00 00 00 1e 00 00 00 52 00 00] 

Is it possible to convert this byte array to an array containing decimal values? Or, if I am interested in a particular index, how can I convert the value of that index to decimal?

Let's say I want to convert index 18, which in a byte array is 01. I use Java btw.

thanks

+6
source share
1 answer
  public int[] bytearray2intarray(byte[] barray) { int[] iarray = new int[barray.length]; int i = 0; for (byte b : barray) iarray[i++] = b & 0xff; return iarray; } 
+14
source

Source: https://habr.com/ru/post/945924/


All Articles