Android Byte Array to Short 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  . ja v  a2s  . co m
            out <<= 8;
        }
        out |= in[0] & 0xff;
        return out;
    }
}

Related

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