Here you can find the source of bytesToShort(byte[] bytes)
Parameter | Description |
---|---|
bytes | - A byte[] containing the bytes to convert. |
public static short bytesToShort(byte[] bytes)
//package com.java2s; //License from project: Open Source License public class Main { /**/* ww w . ja v a 2s .co m*/ * Converts a byte[] of unsigned bytes in big-endian order to a short. * * @param bytes - A byte[] containing the bytes to convert. * * @return A short containing the equivalent signed value of the given bytes. */ public static short bytesToShort(byte[] bytes) { short s = 0; s |= (bytes[0] & 0xFF) << 8; s |= (bytes[1] & 0xFF); return s; } }