Here you can find the source of short2ByteArray(short s)
public static byte[] short2ByteArray(short s)
//package com.java2s; public class Main { public static byte[] short2ByteArray(short s) { byte[] shortBuf = new byte[2]; for (int i = 0; i < 2; i++) { int offset = (shortBuf.length - 1 - i) * 8; shortBuf[i] = (byte) ((s >>> offset) & 0xff); }//from ww w .j a va 2 s . com return shortBuf; } }