Because generally you would want to convert this array back to an int at a later point, here are the methods to convert an array of ints into an array of bytes and vice-versa:
public static byte[] convertToByteArray(final int[] pIntArray)
{
final byte[] array = new byte[pIntArray.length * 4];
for (int j = 0; j < pIntArray.length; j++)
{
final int c = pIntArray[j];
array[j * 4] = (byte)((c & 0xFF000000) >> 24);
array[j * 4 + 1] = (byte)((c & 0xFF0000) >> 16);
array[j * 4 + 2] = (byte)((c & 0xFF00) >> 8);
array[j * 4 + 3] = (byte)(c & 0xFF);
}
return array;
}
public static int[] convertToIntArray(final byte[] pByteArray)
{
final int[] array = new int[pByteArray.length / 4];
for (int i = 0; i < array.length; i++)
array[i] = (((int)(pByteArray[i * 4]) << 24) & 0xFF000000) |
(((int)(pByteArray[i * 4 + 1]) << 16) & 0xFF0000) |
(((int)(pByteArray[i * 4 + 2]) << 8) & 0xFF00) |
((int)(pByteArray[i * 4 + 3]) & 0xFF);
return array;
}
Note that because of sign propagation and such, the "& 0xFF..." are needed when converting back to the int.