move Text hex to Encoder/Decoder
This commit is contained in:
@ -159,4 +159,20 @@ public class Encoder {
|
||||
throw new TimiException(TimiCode.ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节数据转 16 进制字符串
|
||||
*
|
||||
* @param bytes 字节数据
|
||||
* @return 16 进制字符串
|
||||
*/
|
||||
public static String hex(byte[] bytes) {
|
||||
final int l = bytes.length;
|
||||
final char[] c = new char[l << 1];
|
||||
for (int i = 0, j = 0; i < l; i++) {
|
||||
c[j++] = Text.HEX_DIGITS_LOWER[(0xF0 & bytes[i]) >>> 4];
|
||||
c[j++] = Text.HEX_DIGITS_LOWER[0x0F & bytes[i]];
|
||||
}
|
||||
return new String(c);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user