Here you can find the source of bytesToShort(byte[] b)
public static short bytesToShort(byte[] b)
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static short bytesToShort(byte[] b) { ByteBuffer buf = ByteBuffer.wrap(b, 0, 2); buf.order(ByteOrder.LITTLE_ENDIAN); return buf.getShort(); }/*from w w w . j a va 2 s . co m*/ }