Java SE API
ByteBuffer.order
Select byte order for multibyte operations.
Formal Syntax & Structure
java syntaxjava
buffer.order(ByteOrder.BIG_ENDIAN)Working Example
Example Snippetjava
public class Main {
public static void main(String[] args) throws Exception { var b = java.nio.ByteBuffer.allocateDirect(4).order(java.nio.ByteOrder.BIG_ENDIAN); b.putInt(0, 42); System.out.println(b.getInt(0)); System.out.println(b.get(3)); }}