Java ByteBuffer create
import java.nio.ByteBuffer; public class Main { public static void main(String[] args) { ByteBuffer bb = ByteBuffer.allocate(2); System.out.println("Default Byte Order: " + bb.order()); bb.putShort((short) 67); bb.flip();/*from w w w. j ava 2 s .c om*/ System.out.println("Byte Order: " + bb.order()); while (bb.hasRemaining()) { System.out.print(bb.get() + " "); } } }