Java ByteBuffer store short type value
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 . jav a2 s.com System.out.println("Byte Order: " + bb.order()); while (bb.hasRemaining()) { System.out.print(bb.get() + " "); } } }