Here you can find the source of bytesToInts(byte[] data)
Parameter | Description |
---|---|
data | a byte array of arbitrary size |
public static int[] bytesToInts(byte[] data)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w .ja v a 2s . c o m * Convert an array of bytes into a new array of integers. The order of 4 * bytes each is reversed and then they are combined into a new integer. If * data has a length that is not a multiple of 4, the remaining bytes are * simply dropped. * * @param data * a byte array of arbitrary size * @return an integer array */ public static int[] bytesToInts(byte[] data) { int[] a = new int[data.length / 4]; for (int i = 0; i < a.length; i++) { a[i] = (data[i * 4] & 0xFF) | ((data[i * 4 + 1] & 0xFF) << 8) | ((data[i * 4 + 2] & 0xFF) << 16) | ((data[i * 4 + 3] & 0xFF) << 24); } return a; } }