Java Byte Array to Short bytesToShortLittleEndian(final byte[] vals, final int from)

Here you can find the source of bytesToShortLittleEndian(final byte[] vals, final int from)

Description

bytes into single short

License

Open Source License

Parameter

Parameter Description
vals raw data
from offset in array

Return

int

Declaration

public static int bytesToShortLittleEndian(final byte[] vals, final int from) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w  w  .  jav a 2 s.c om*/
     * <code>bytes</code> into single <code>short</code>
     * @param vals raw data
     * @param from offset in array
     * @return int
     */
    public static int bytesToShortLittleEndian(final byte[] vals, final int from) {
        return ((vals[from + 1] & 0xFF) << 8) + (vals[from] & 0xFF);
    }
}

Related

  1. bytesToShort(final byte byte0, final byte byte1)
  2. bytesToShort(final byte[] aBuffer, final int aPos)
  3. bytesToShort(final byte[] data)
  4. bytesToShort16(byte highByte, byte lowByte)
  5. bytesToShortBE(byte[] bytes, int off)
  6. bytesToShorts(byte byteBuffer[])
  7. bytesToShorts(byte[] byteData)
  8. bytesToShorts(byte[] src, int srcPos, short[] dest, int destPos, int length, boolean bigEndian)
  9. byteToShort(byte[] b)