Java tutorial
//package com.java2s; //License from project: Open Source License import java.nio.ByteBuffer; import java.nio.ByteOrder; public class Main { public static synchronized byte[] int16tobyte(int a) { byte[] inttemp = new byte[2]; inttemp[1] = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(a).get(1); inttemp[0] = ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(a).get(0); return inttemp; } }