Java Byte Array to Short bytes2short(byte[] b)

Here you can find the source of bytes2short(byte[] b)

Description

to short.

License

Apache License

Parameter

Parameter Description
b byte array.

Return

short.

Declaration

public static short bytes2short(byte[] b) 

Method Source Code

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

public class Main {
    /**/*  w ww . ja va 2 s. c  o  m*/
     * to short.
     * 
     * @param b byte array.
     * @return short.
     */
    public static short bytes2short(byte[] b) {
        return bytes2short(b, 0);
    }

    /**
     * to short.
     * 
     * @param b byte array.
     * @param off offset.
     * @return short.
     */
    public static short bytes2short(byte[] b, int off) {
        return (short) (((b[off + 1] & 0xFF) << 0) + ((b[off + 0]) << 8));
    }
}

Related

  1. bufferToShort(byte[] ioBuffer)
  2. byte2short(byte[] ba)
  3. byte2short(byte[] data)
  4. byte2short(byte[] value, int offset)
  5. byte2Short(int loc, byte b[])
  6. bytes2Short(byte[] bytes)
  7. bytes2short(byte[] bytes, int offset, boolean bigEndian)
  8. bytes2Short(byte[] input)
  9. bytes2short(byte[] src)