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

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

Description

byte To Short

License

Open Source License

Declaration

public static short byteToShort(byte[] b) 

Method Source Code

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

public class Main {
    public static short byteToShort(byte[] b) {
        short s = 0;
        short s0 = (short) (b[0] & 0xff);
        short s1 = (short) (b[1] & 0xff);
        s1 <<= 8;//from   w ww .  j a  v a2 s .  c  om
        s = (short) (s0 | s1);
        return s;
    }
}

Related

  1. bytesToShortBE(byte[] bytes, int off)
  2. bytesToShortLittleEndian(final byte[] vals, final int from)
  3. bytesToShorts(byte byteBuffer[])
  4. bytesToShorts(byte[] byteData)
  5. bytesToShorts(byte[] src, int srcPos, short[] dest, int destPos, int length, boolean bigEndian)
  6. byteToShort(byte[] byteData, boolean writeLittleEndian)
  7. byteToShort(byte[] data, int length, boolean reduceStereo)