Java Byte Array to Short bytesToShort(byte[] buf)

Here you can find the source of bytesToShort(byte[] buf)

Description

bytes To Short

License

Apache License

Declaration

public static short bytesToShort(byte[] buf) 

Method Source Code

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

public class Main {
    public static short bytesToShort(byte[] buf) {
        return (short) (((0xff & buf[0]) << 8) | (0xff & buf[1]));
    }//from  w  w w .ja v a  2 s .  c om

    public static short bytesToShort(byte[] buf, int startIdx) {
        return (short) (((0xff & buf[startIdx]) << 8) | (0xff & buf[startIdx + 1]));
    }
}

Related

  1. bytesToShort(byte A, byte B)
  2. bytesToShort(byte a, byte b, boolean swapBytes)
  3. bytesToShort(byte b1, byte b2)
  4. bytesToShort(byte byte1, byte byte2)
  5. bytesToShort(byte hiByte, byte loByte)
  6. bytesToShort(byte[] buffer, int index)
  7. bytesToShort(byte[] bytes)
  8. bytesToShort(byte[] bytes)
  9. bytesToShort(byte[] bytes)