Java ByteBuffer Read readResBit15(ByteBuffer fromBuffer)

Here you can find the source of readResBit15(ByteBuffer fromBuffer)

Description

read Res Bit

License

Apache License

Declaration

static int readResBit15(ByteBuffer fromBuffer) 

Method Source Code

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

import java.nio.ByteBuffer;

public class Main {
    static int readResBit15(ByteBuffer fromBuffer) {
        int b = readUnsignedByte(fromBuffer);
        if ((b & 0x80) != 0) {
            return (short) (((b & 0x7F) << 8) + readUnsignedByte(fromBuffer));
        }//from  ww  w  . j a  v a  2s . co m

        return (short) b;
    }

    static int readUnsignedByte(ByteBuffer fromBuffer) {
        short val = fromBuffer.get();
        if (val < 0)
            val &= 0xFF;
        return val;
    }
}

Related

  1. readLink(ByteBuffer bb)
  2. readNewLine(ByteBuffer buf)
  3. readNullTerminatedString(ByteBuffer buf)
  4. readObject(ByteBuffer byteBuffer)
  5. readReal(ByteBuffer bb)
  6. readShortLE(ByteBuffer buf, int i)
  7. readShortLength(ByteBuffer bb)
  8. readShorts(final ByteBuffer bb, final int length)
  9. readShortString(ByteBuffer buffer)