Android Big Endian Convert getShort(byte[] data, int i, boolean bigEndian)

Here you can find the source of getShort(byte[] data, int i, boolean bigEndian)

Description

get Short

Declaration

public static short getShort(byte[] data, int i, boolean bigEndian) 

Method Source Code

//package com.java2s;

public class Main {
    public static short getShort(byte[] data, int i, boolean bigEndian) {
        if (bigEndian)
            return (short) ((data[i] << 8) + (data[i + 1] & 0xff));
        else// w w  w  . ja va2  s . co m
            return (short) ((data[i + 1] << 8) + (data[i] & 0xff));
    }
}

Related

  1. toggleLongEndian(byte[] b)
  2. toggleLongEndian(byte[] b, int off, int len)
  3. toggleShortEndian(byte[] b)
  4. toggleShortEndian(byte[] b, int off, int len)
  5. getInt(byte[] data, int i, boolean bigEndian)
  6. switchEndian(int i)
  7. switchEndian(long l)
  8. switchEndian(short i)
  9. setBigIndianInBytesArray(byte[] toPutIn, int startidx, long theNumber, int len)