Here you can find the source of bytes2Int(byte[] bytes, int defaultValue)
public static int bytes2Int(byte[] bytes, int defaultValue)
//package com.java2s; //License from project: Open Source License public class Main { public static int bytes2Int(byte[] bytes, int defaultValue) { if (bytes == null) { return defaultValue; } else {// w w w . j a v a 2 s.c o m return bytes2Int(bytes); } } /** * convert bytes to integer. high byte store at left. * @param bytes * @return */ public static int bytes2Int(byte[] bytes) { int num = 0; for (int ix = 0; ix < bytes.length; ++ix) { num <<= 8; num |= (bytes[ix] & 0xff); } return num; } }