Here you can find the source of getUnsignedInt16LSBMSB(ByteBuffer byteBuffer)
public static int getUnsignedInt16LSBMSB(ByteBuffer byteBuffer)
//package com.java2s; /*//from www . j a v a 2 s . c o m * COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Notice * * The contents of this file are subject to the COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) * Version 1.0 (the "License"); you may not use this file except in * compliance with the License. A copy of the License is available at * http://www.opensource.org/licenses/cddl1.txt * * The Original Code is Drombler.org. The Initial Developer of the * Original Code is Florian Brunner (Sourceforge.net user: puce). * Copyright 2014 Drombler.org. All Rights Reserved. * * Contributor(s): . */ import java.nio.ByteBuffer; public class Main { private static final short MAX_UNSIGNED_BYTE = 0xFF; private static final int NUM_INTEGER_BITS = 4; private static final int NUM_SHORT_BITS = 2; public static int getUnsignedInt16LSBMSB(ByteBuffer byteBuffer) { byte[] bytes = getBytes(byteBuffer, 2 * NUM_SHORT_BITS); int value = 0; for (int i = 0; i < NUM_SHORT_BITS; i++) { value += getUnsignedByte(bytes[i]) << (NUM_INTEGER_BITS * i); } return value; } private static byte[] getBytes(ByteBuffer byteBuffer, int length) { byte[] dst = new byte[length]; byteBuffer.get(dst); return dst; } public static short getUnsignedByte(byte value) { return (short) (value & MAX_UNSIGNED_BYTE); } }