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;

public class Main {
    public static short toShort(byte[] b) {
        short value = 0;
        for (int x = 0; x < b.length; x++) {
            value |= b[x] & 0xFF;//  ww  w  .  j a v  a2  s  .  c  om
            // if it's the last one, don't shift
            if (x != b.length - 1) {
                value <<= 8;
            }
        }
        return value;
    }
}

Related

  1. toShort(byte... b)
  2. toShort(byte... b)
  3. toShort(byte[] b)
  4. toShort(byte[] b)
  5. toShort(byte[] b)
  6. toShort(byte[] b)
  7. toShort(byte[] b, int off, boolean bigEndian)
  8. toShort(byte[] b, int offset)
  9. toShort(byte[] buf, int pos)