我是java的新手.我收到字节数组中的UDP数据.字节数组的每个元素都具有十六进制值.我需要将每个元素转换为整数.
如何将其转换为整数?
示例代码:
public int[] bytearray2intarray(byte[] barray) { int[] iarray = new int[barray.length]; int i = 0; for (byte b : barray) iarray[i++] = b & 0xff; // "and" with 0xff since bytes are signed in java return iarray; }