Java examples for java.nio:ByteBuffer Endian
Puts the 24 least significant bits of value in to the byte buffer, big endian.
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 ww . j a va 2s. c om*/ * Puts the 24 least significant bits of value in to the byte buffer, big * endian. * * @param buf * @param value */ final public static void putUnsigned24(ByteBuffer buf, int value) { buf.put((byte) (value >> 16)); buf.put((byte) (value >> 8)); buf.put((byte) value); } /** * Puts the 24 least significant bits of value in to the byte buffer, big * endian. * * @param buf * @param value */ final public static void putUnsigned24(ByteBuffer buf, int index, int value) { buf.put(index, (byte) (value >> 16)); index++; buf.put(index, (byte) (value >> 8)); index++; buf.put(index, (byte) value); } }