Here you can find the source of toBytes(short s)
public static byte[] toBytes(short s)
//package com.java2s; //License from project: LGPL public class Main { public static byte[] toBytes(short s) { return new byte[] { (byte) (s & 0x00FF), (byte) ((s & 0xFF00) >> 8) }; }/* w w w . j ava 2 s. com*/ }