Here you can find the source of bytesToShort(byte[] bytes, int off, boolean bigEndian)
public static short bytesToShort(byte[] bytes, int off, boolean bigEndian)
//package com.java2s; //License from project: Open Source License public class Main { public static short bytesToShort(byte[] bytes, int off, boolean bigEndian) { byte b1 = bytes[off], b2 = bytes[off + 1]; if (!bigEndian) { byte tmp = b1; b1 = b2;//w w w . j a v a 2s . c o m b2 = tmp; } return (short) (((b1 & 0xFF) << 8) | (b2 & 0xFF)); } }