Returns 31 bits of an int, removing the sign bit. - Java File Path IO

Java examples for File Path IO:Byte Array

Description

Returns 31 bits of an int, removing the sign bit.

Demo Code


import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.Iterator;
import org.apache.log4j.Logger;

public class Main{
    /**//from   w w w.  j  a v a2 s  .c o  m
     * Returns 31 bits of an int, removing the sign bit.
     * 
     * @param buf
     * @return
     */
    final public static int getUnsigned31(ByteBuffer buf) {
        return buf.getInt() & 0x7fffffff;
    }
}

Related Tutorials