Java Short Number Create toShort(byte... b)

Here you can find the source of toShort(byte... b)

Description

to Short

License

Open Source License

Declaration

public static short toShort(byte... b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static short toShort(byte... b) {
        return (short) toLong(b);
    }// www  .ja v a2s  .  c o m

    public static long toLong(byte... b) {
        int mask = 0xff;
        int temp = 0;
        long res = 0;
        int byteslen = b.length;
        if (byteslen > 8) {
            return Long.valueOf(0L);
        }
        for (int i = 0; i < byteslen; i++) {
            res <<= 8;
            temp = b[i] & mask;
            res |= temp;
        }
        return res;
    }
}

Related

  1. toShort(byte b0, byte b1)
  2. toShort(byte byte0, byte byte1)
  3. toShort(byte mostSignificant, byte leastSignificant)
  4. toShort(byte msb, byte lsb)
  5. toShort(byte... b)
  6. toShort(byte[] b)
  7. toShort(byte[] b)
  8. toShort(byte[] b)
  9. toShort(byte[] b)