Here you can find the source of bytesToInt(final byte[] bytes)
public static int bytesToInt(final byte[] bytes)
//package com.java2s; //License from project: LGPL public class Main { public static int bytesToInt(final byte[] bytes) { assertNotNull("bytes", bytes); if (bytes.length != 4) throw new IllegalArgumentException("bytes.length != 4"); return bytesToInt(bytes, 0); }//from w w w. j av a 2s . co m public static int bytesToInt(final byte[] bytes, final int index) { assertNotNull("bytes", bytes); if (bytes.length - index < 4) throw new IllegalArgumentException("bytes.length - index < 4"); int value = 0; for (int i = 0; i < 4; ++i) value |= ((long) (bytes[index + i] & 0xff)) << (8 * (4 - 1 - i)); return value; } public static final <T> T assertNotNull(final String name, final T object) { if (object == null) throw new IllegalArgumentException(String.format("%s == null", name)); return object; } }