in ByteBuffer Native Byte Order - Java java.nio

Java examples for java.nio:ByteBuffer

Description

in ByteBuffer Native Byte Order

Demo Code


import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;

public class Main{
    public static ByteBuffer inNativeByteOrder(ByteBuffer buf) {
        if (buf.order().equals(Utils.NATIVE_BYTE_ORDER)) {
            return buf;
        } else {//from www. ja  v  a2s.c o m
            return buf.duplicate().order(Utils.NATIVE_BYTE_ORDER);
        }
    }
}

Related Tutorials