Java tutorial
//package com.java2s; public class Main { public static byte[] shortToBytes(short number) { int temp = number; byte[] bytes = new byte[2]; for (int i = 0; i < bytes.length; i++) { bytes[i] = new Integer(temp & 0xff).byteValue(); temp = temp >> 8; } return bytes; } }