Java Integer Array to Byte Array intArray2Bytes(int[] array)

Here you can find the source of intArray2Bytes(int[] array)

Description

int Array Bytes

License

Open Source License

Declaration

public static byte[] intArray2Bytes(int[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[] intArray2Bytes(int[] array) {
        byte[] bytes = new byte[array.length * 4];
        int byteIndex = 0;
        int arrayIndex = 0;
        while (arrayIndex < array.length) {
            int num = array[arrayIndex++];
            bytes[byteIndex++] = (byte) ((num >> 24) & 0xff);
            bytes[byteIndex++] = (byte) ((num >> 16) & 0xff);
            bytes[byteIndex++] = (byte) ((num >> 8) & 0xff);
            bytes[byteIndex++] = (byte) (num & 0xff);
        }//from  w  ww  .  ja va2  s. c o m
        return bytes;
    }
}

Related

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