Here you can find the source of toIntArray(final byte[] byteArray)
public static int[] toIntArray(final byte[] byteArray)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static int[] toIntArray(final byte[] byteArray) { if (byteArray.length % 2 != 0) { throw new IllegalArgumentException( "Cannot convert an odd sized byte array into an int array."); }// w w w .ja va 2s . c o m int[] intArray = new int[byteArray.length / 2]; for (int i = 0; i < byteArray.length; i += 2) { intArray[i / 2] = toInt(byteArray[i], byteArray[i + 1]); } return intArray; } public static int toInt(final byte lowOrderByte, final byte highOrderByte) { return toInt(lowOrderByte, highOrderByte, ByteOrder.LITTLE_ENDIAN); } public static int toInt(final byte lowOrderByte, final byte highOrderByte, final ByteOrder byteOrder) { ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4); byteBuffer.order(byteOrder); byteBuffer.put(lowOrderByte); byteBuffer.put(highOrderByte); byteBuffer.put((byte) 0x00); byteBuffer.put((byte) 0x00); byteBuffer.flip(); return byteBuffer.getInt(); } }