How to convert a Byte Array to an Int Array

You've said in the comments that you want four bytes from the input array to correspond to one integer on the output array, so that works out nicely.

Depends on whether you expect the bytes to be in big-endian or little-endian order, but...

 IntBuffer intBuf =
   ByteBuffer.wrap(byteArray)
     .order(ByteOrder.BIG_ENDIAN)
     .asIntBuffer();
 int[] array = new int[intBuf.remaining()];
 intBuf.get(array);

Done, in three lines.


Converting every 4 bytes of a byte array into an integer array:

public int[] convert(byte buf[]) {
   int intArr[] = new int[buf.length / 4];
   int offset = 0;
   for(int i = 0; i < intArr.length; i++) {
      intArr[i] = (buf[3 + offset] & 0xFF) | ((buf[2 + offset] & 0xFF) << 8) |
                  ((buf[1 + offset] & 0xFF) << 16) | ((buf[0 + offset] & 0xFF) << 24);  
   offset += 4;
   }
   return intArr;
}