Java Convert via ByteBuffer toShort(byte[] bytes, int index)

Here you can find the source of toShort(byte[] bytes, int index)

Description

to Short

License

Apache License

Declaration

public static short toShort(byte[] bytes, int index) 

Method Source Code

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

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    public static short toShort(byte[] bytes, int index) {

        return ByteBuffer.wrap(bytes, index, 2).order(ByteOrder.LITTLE_ENDIAN).getShort();
        //return (short) ((0xff & bytes[index]) | (0xff & (bytes[index + 1] << 8)));
    }/*from  w w  w. j  a  v  a 2  s  .c  o  m*/
}

Related

  1. toMappedBuffer(File file)
  2. toMappedBuffer(File file)
  3. toMappedBuffer(File file, long start, long end)
  4. toMsftBinary(UUID uuid)
  5. toShort(byte firstByte, byte secondByte)
  6. toShort(final byte byteValue, final ByteOrder byteOrder)
  7. toShortArray(byte[] arr)
  8. toShortArray(final byte[] byteArray)
  9. toSimpleList(List attrValues)