Java Byte Array to Int Bytes2Int16(byte[] sour, int offset)

Here you can find the source of Bytes2Int16(byte[] sour, int offset)

Description

Bytes Int

License

Open Source License

Declaration

public static int Bytes2Int16(byte[] sour, int offset) 

Method Source Code

//package com.java2s;

public class Main {

    public static int Bytes2Int16(byte[] sour, int offset) {
        int ret = Bytes2Uint16(sour, offset);
        return ((ret & 0x8000) == 0x8000) ? 0xFFFF0000 | ret : ret;
    }//  w w  w . ja v a 2s .c o m

    public static int Bytes2Uint16(byte[] sour, int offset) {
        return (((sour[offset] << 8) & 0xFF00) | (sour[offset + 1] & 0x00FF));
    }
}

Related

  1. bytes2Int(byte[] bytes, int offset)
  2. bytes2int(byte[] bytes, int offset, boolean bigEndian)
  3. bytes2int(byte[] in, int index1, int index2, int index3)
  4. bytes2int(byte[] src)
  5. bytes2Int(byte[] src, int start)
  6. Bytes2Int32(byte[] sour, int offset)
  7. Bytes2Int64(byte[] sour, int offset)
  8. bytes2IntArray(byte[] bytes)
  9. bytes2Integer(byte[] byteVal)