Here you can find the source of bytes2int(byte[] in, int index1, int index2, int index3)
public static int[] bytes2int(byte[] in, int index1, int index2, int index3)
//package com.java2s; /*//from www .j a v a2 s . c o m * Copyright 2013, Morten Nobel-Joergensen * * License: The BSD 3-Clause License * http://opensource.org/licenses/BSD-3-Clause */ public class Main { public static int[] bytes2int(byte[] in, int index1, int index2, int index3) { int[] out = new int[in.length / 3]; for (int i = 0; i < out.length; i++) { int index = i * 3; int b1 = (in[index + index1] & 0xff) << 16; int b2 = (in[index + index2] & 0xff) << 8; int b3 = in[index + index3] & 0xff; out[i] = b1 | b2 | b3; } return out; } public static int[] bytes2int(byte[] in, int index1, int index2, int index3, int index4) { int[] out = new int[in.length / 4]; for (int i = 0; i < out.length; i++) { int index = i * 4; int b1 = (in[index + index1] & 0xff) << 24; int b2 = (in[index + index2] & 0xff) << 16; int b3 = (in[index + index3] & 0xff) << 8; int b4 = in[index + index4] & 0xff; out[i] = b1 | b2 | b3 | b4; } return out; } }