public class ConvToByte {
/**
* short 类型转换成 byte 数组
*
* @param param
* 待转的 short
* @return
*
* @author li
* @date 2014-1-16 上午 10:03:47
*/
public static byte[] shortToByteArr(short param) {
byte[] arr = new byte[2];
arr[0] = (byte) ((param >> 8) & 0xff);
arr[1] = (byte) (param & 0xff);
return arr;
}
/**
* int 类型转换成 byte 数组
*
* @param param
* 待转的 int
* @return
*
* @author li
* @date 2014-1-16 上午 10:03:47
*/
public static byte[] intToByteArr(int param) {
byte[] arr = new byte[4];
arr[0] = (byte) ((param >> 24) & 0xff);
arr[1] = (byte) ((param >> 16) & 0xff);
arr[2] = (byte) ((param >> 8) & 0xff);
arr[3] = (byte) (param & 0xff);
return arr;
}
/**
* long 类型转换成 byte 数组
*
* @param param
* 待转的 long
* @return
*