Return 24 unsigned bits as an integer. - Java File Path IO

Java examples for File Path IO:Byte Array

Description

Return 24 unsigned bits as an integer.

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  ww w .ja  v a  2 s  .c o m*/
     * Return 24 unsigned bits as an integer. Big endian.
     * 
     * @param buf
     * @return
     */
    final public static int getUnsigned24(ByteBuffer buf) {
        int length = (0xff & buf.get());
        length = (length << 8) | (0xff & buf.get());
        length = (length << 8) | (0xff & buf.get());
        return length;
    }
}

Related Tutorials