Android Byte Array to Short bytesToShort(byte[] b)

Here you can find the source of bytesToShort(byte[] b)

Description

bytes To Short

Declaration

public static short bytesToShort(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    public static short bytesToShort(byte[] b) {
        short s0 = (short) (b[0] & 0xff);
        short s1 = (short) (b[1] & 0xff);
        s1 <<= 8;/*from   w  w  w .  j  a v  a2s  .co  m*/
        return (short) (s0 | s1);
    }
}

Related

  1. bytesToShort(byte[] b)
  2. toShort(byte[] in)