Here you can find the source of checkSum2(byte[] data)
public static int checkSum2(byte[] data)
//package com.java2s; public class Main { public static int checkSum2(byte[] data) { long checksum = 0; int length = data.length; byte[] temp = new byte[2]; for (int index = 0; index < length - 1; index += 2) { temp[0] = data[index];/*from www .jav a 2s . c o m*/ temp[1] = data[index + 1]; int val = bytes2short(temp) & 0x0000FFFF; checksum += val; } return (int) (checksum & 0xFFFFFFFF); } public static short bytes2short(byte[] data) { short val = 0; val |= data[0] & 0x00FF; val |= data[1] << 8; return val; } }