标签:har eth null art equals etl static case uppercase
/**
*
* @Title: hexStringToBytes
* @Description: 将十六进制字符串转化为十六进制byte[]
* @param hexString
* @return
* @return: byte[]
*/
public static byte[] hexStringToBytes(String hexString) {
if (hexString == null || hexString.equals("")) {
return null;
}
hexString = hexString.toUpperCase();
int length = hexString.length() / 2;
char[] hexChars = hexString.toCharArray();
byte[] d = new byte[length];
for (int i = 0; i < length; i++) {
int pos = i * 2;
d[i] = (byte) (charToByte(hexChars[pos]) << 4 | charToByte(hexChars[pos + 1]));
}
return d;
}
private static byte charToByte(char c) {
return (byte) "0123456789ABCDEF".indexOf(c);
}
//取高八位
public static int getHighByte(int num){
return 0xffff&(num>>8);
}
//取低八位
public static int getLowByte(int num){
return (0xffff&(num<<8))>>8;
}
标签:har eth null art equals etl static case uppercase
原文地址:http://www.cnblogs.com/lichunyang321/p/6689450.html