Here you can find the source of bytesToShort(byte[] shortBytes)
public static short bytesToShort(byte[] shortBytes)
//package com.java2s; /*//from www.j av a 2 s. c om * @(#)ByteConvertUtil.java V0.0.1 2015-2-3, ????1:37:07 * * Copyright 2015 www.ifood517.com. All rights reserved. * www.ifood517.com PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ public class Main { public static short bytesToShort(byte[] shortBytes) { byte[] data = new byte[2]; System.arraycopy(shortBytes, 0, data, 0, 2); return (short) (((data[0] << 8) | data[1] & 0xff)); } public static short bytesToShort(byte[] shortBytes, int index) { byte[] data = new byte[2]; System.arraycopy(shortBytes, index, data, 0, 2); return (short) (((data[0] << 8) | data[1] & 0xff)); } }