Returns 16 unsigned bits as an integer. - Java File Path IO

Java examples for File Path IO:Byte Array

Description

Returns 16 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  w w  w  .  j av  a2  s . c  o m*/
     * Returns 16 unsigned bits as an integer. Big endian.
     * 
     * @param buf
     * @return
     */
    final public static int getUnsignedShort(ByteBuffer buf) {
        return buf.getShort() & 0xffff;
    }
}

Related Tutorials