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

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

Description

to Short

License

LGPL

Declaration

public static short toShort(byte[] in) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static short toShort(byte[] in) {
        short out = 0;
        for (int i = in.length - 1; i > 0; i--) {
            out |= in[i] & 0xff;/*from w  w w  .j a v a2s .com*/
            out <<= 8;
        }
        out |= in[0] & 0xff;
        return out;
    }
}

Related

  1. bytesToShort(byte[] b)
  2. bytesToShort(byte[] b)
  3. byte2Short(byte bin)
  4. byteArray2Short(byte[] b)
  5. byteArrayToShort(byte[] b, int offset)
  6. bytesBE2shorts(byte[] b)