in ByteBuffer Little Endian Order - Java java.nio

Java examples for java.nio:ByteBuffer Endian

Description

in ByteBuffer Little Endian Order

Demo Code


//package com.java2s;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

public class Main {
    public static ByteBuffer inLittleEndianOrder(ByteBuffer buf) {
        if (buf.order().equals(ByteOrder.LITTLE_ENDIAN)) {
            return buf;
        } else {/*from  w  w  w .ja va 2  s .c o m*/
            return buf.duplicate().order(ByteOrder.LITTLE_ENDIAN);
        }
    }
}

Related Tutorials