Java Integer Array to Byte Array intArrayToByteArray(int[] ai)

Here you can find the source of intArrayToByteArray(int[] ai)

Description

int Array To Byte Array

License

LGPL

Declaration

public static byte[] intArrayToByteArray(int[] ai) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static byte[] intArrayToByteArray(int[] ai) {
        byte[] ab = new byte[ai.length * 4];

        for (int i = 0; i < ai.length; i++) {
            ab[i * 4] = (byte) (ai[i] >> 24);
            ab[i * 4 + 1] = (byte) (ai[i] >> 16);
            ab[i * 4 + 2] = (byte) (ai[i] >> 8);
            ab[i * 4 + 3] = (byte) ai[i];
        }//w ww.  j a v a  2s .  c om

        return ab;
    }
}

Related

  1. convertIntArrayToByteArray(int[] data)
  2. convertIntArrayToByteArray(int[] myIntArray, int bytesPerInt)
  3. intArray2Bytes(int[] array)
  4. intArrayToByteArray(int[] data)
  5. intArrayToByteArray(int[] ints)
  6. intArrayToBytes(int[] d)