Java ByteBuffer Read readCInt(ByteBuffer buffer)

Here you can find the source of readCInt(ByteBuffer buffer)

Description

read C Int

License

Apache License

Declaration

public static final int readCInt(ByteBuffer buffer) 

Method Source Code


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

import java.nio.ByteBuffer;

public class Main {
    public static final int readCInt(ByteBuffer buffer) {
        final byte head = buffer.get();
        // -128 = short byte, -127 == 4 byte
        if (head > -127 && head <= 127) {
            return head;
        }//from  w  w  w  . ja v  a 2s .co m
        if (head == -128) {
            return buffer.getShort();
        } else {
            return buffer.getInt();
        }
    }
}

Related

  1. readBufferFully(FileChannel fc, ByteBuffer buf, int startPos)
  2. readByteBuffer(ByteBuffer buf)
  3. readByteBufferFromFile(String filepath)
  4. readChars(ByteBuffer bb, int length)
  5. readCharsUTF8(ByteBuffer bb, int length)
  6. readCString(ByteBuffer buf, int len)
  7. readDERString(ByteBuffer buf)
  8. readDword(ByteBuffer buffer)
  9. readFileToByteBuffer(File file)