Here you can find the source of shortToBytes(short number)
public static byte[] shortToBytes(short number)
//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;// w ww. java2 s.co m } return bytes; } }