/**
* 2字节
* 低位在前,高位在后
*
* @param n
* @return
*/
public static byte[] unlong2H2bytes(long n) {
byte[] b = new byte[2];
b[0] = (byte) (n & 0xff);
b[1] = (byte) (n >> 8 & 0xff);
return b;
}
/**
* byte数组转为十六进制字符串
*
* @param bytes
* @return
*/
public static String byte2Hex(byte[] bytes) {
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < bytes.length; i++) {
String hex = Integer.toHexString(0xff & bytes[i]);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}