Here you can find the source of short2bytes(short val)
public static byte[] short2bytes(short val)
//package com.java2s; public class Main { public static byte[] short2bytes(short val) { byte[] data = new byte[2]; data[0] = (byte) (val & 0xFF); data[1] = (byte) (val >> 8 & 0xFF); return data; }//from w w w.j a va2s.c o m }