3

I have stored an integer value into 4 bytes and I have trouble converting it back into integer.

byte[] pom = ByteBuffer.allocate(4).putInt(60000).array();

In each byte I have an hexadecimal part of my int number.

arr[0] = 0
arr[1] = 0
arr[2] = ea
arr[3] = 60

How can I convert it back into integer?

mhSangar
  • 457
  • 3
  • 12
MetalSalmon
  • 35
  • 1
  • 1
  • 6

1 Answers1

15

Just use ByteBuffer.getInt():

int pomAsInt = ByteBuffer.wrap(pom).getInt();
Mureinik
  • 297,002
  • 52
  • 306
  • 350