Java ByteBuffer to Int readIntMSB(ByteBuffer logBuf)

Here you can find the source of readIntMSB(ByteBuffer logBuf)

Description

Read a int from the log in MSB order.

License

Open Source License

Declaration

public static int readIntMSB(ByteBuffer logBuf) 

Method Source Code


//package com.java2s;
/*-//from   www . j  a v a2  s . com
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2002-2010 Oracle.  All rights reserved.
 *
 */

import java.nio.ByteBuffer;

public class Main {
    /**
     * Read a int from the log in MSB order.  Used for ordered keys.
     */
    public static int readIntMSB(ByteBuffer logBuf) {
        int ret = (logBuf.get() & 0xFF) << 24;
        ret += (logBuf.get() & 0xFF) << 16;
        ret += (logBuf.get() & 0xFF) << 8;
        ret += (logBuf.get() & 0xFF) << 0;
        return ret;
    }
}

Related

  1. readInt16(ByteBuffer bb)
  2. readInt32(ByteBuffer bb)
  3. readInt8(final ByteBuffer buffer)
  4. readIntEquals(ByteBuffer buf, int i, int j)
  5. readIntLE(ByteBuffer buf, int i)
  6. readIntoBuffer(SocketChannel channel, ByteBuffer buf, int sleepMsecs)
  7. readInts(final ByteBuffer bb, final int length)
  8. readInts4(final ByteBuffer buffer, final int[] array, final int count)
  9. readUnsigned(ByteBuffer in, int size)