Here you can find the source of bytes2short(byte[] bytes, int offset, boolean bigEndian)
public static short bytes2short(byte[] bytes, int offset, boolean bigEndian)
//package com.java2s; //License from project: Apache License public class Main { public static short bytes2short(byte[] bytes, int offset, boolean bigEndian) { short val = 0; if (bigEndian) { val += (bytes[offset + 0] & 0xff) << 8; val += (bytes[offset + 1] & 0xff); } else {// ww w . ja v a 2 s. c o m val += (bytes[offset + 1] & 0xff) << 8; val += (bytes[offset + 0] & 0xff); } return val; } public static short bytes2short(byte[] bytes, boolean bigEndian) { return bytes2short(bytes, 0, bigEndian); } }