Here you can find the source of bytesToInt16(byte highByte, byte lowByte)
public static int bytesToInt16(byte highByte, byte lowByte)
//package com.java2s; public class Main { /**/* w ww .ja v a 2s .c om*/ * Converts 2 bytes to a signed integer sample with 16bit range. * <p> This is a reference function. */ public static int bytesToInt16(byte highByte, byte lowByte) { return (highByte << 8) | (lowByte & 0xFF); } /** * Converts 2 successive bytes starting at <code>byteOffset</code> in * <code>buffer</code> to a signed integer sample with 16bit range. * <p> * For little endian, buffer[byteOffset] is interpreted as low byte, * whereas it is interpreted as high byte in big endian. * <p> This is a reference function. */ public static int bytesToInt16(byte[] buffer, int byteOffset, boolean bigEndian) { return bigEndian ? ((buffer[byteOffset] << 8) | (buffer[byteOffset + 1] & 0xFF)) : ((buffer[byteOffset + 1] << 8) | (buffer[byteOffset] & 0xFF)); } }