Android Byte Array to Short Convert toShort(byte[] data)

Here you can find the source of toShort(byte[] data)

Description

to Short

Declaration

public static short toShort(byte[] data) 

Method Source Code

//package com.java2s;

public class Main {
    public static short toShort(byte[] data) {
        if (data == null || data.length != 2)
            return 0x0;
        // ----------
        return (short) ((0xff & data[0]) << 8 | (0xff & data[1]) << 0);
    }/*from   ww  w  .j a  va 2  s  .  c  o m*/
}

Related

  1. getShort(byte[] buf, boolean bigEndian)
  2. getShort(byte[] buf, int pos, boolean bigEndian)
  3. getShort(byte[] bytes)
  4. toShort(byte[] b, int pos)
  5. toShort(byte[] data)
  6. makeShort(byte b1, byte b0)
  7. bytes2short(byte[] data)
  8. ByteToString(byte[] byteArray)