Android Array Convert convertByteArrayToIntArray(byte[] bytes)

Here you can find the source of convertByteArrayToIntArray(byte[] bytes)

Description

Converts a byte array to an int array.

License

Apache License

Parameter

Parameter Description
bytes a parameter

Declaration

public static int[] convertByteArrayToIntArray(byte[] bytes) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    /**/*  www. j  a v  a2  s  .  c  o m*/
     * Converts a byte array to an int array.
     * @param bytes
     * @return
     */
    public static int[] convertByteArrayToIntArray(byte[] bytes) {
        if (bytes == null)
            return null;

        int count = bytes.length / 4;
        int[] intArray = new int[count];
        ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
        for (int i = 0; i < count; i++) {
            intArray[i] = byteBuffer.getInt();
        }
        return intArray;
    }
}

Related

  1. convertByteArrayToLongArray(byte[] bytes)
  2. convertDoubleArrayToByteArray(double[] doubleArray)
  3. convertDoubleConsonant(byte[] b)