| | |
| | | public static Object getBean(String name) { |
| | | return getApplicationContext().getBean(name); |
| | | } |
| | | |
| | | /** |
| | | * Byte字节转Hex |
| | | * @param b 字节 |
| | | * @return Hex |
| | | */ |
| | | public static String byteToHex(byte b) |
| | | { |
| | | String hexString = Integer.toHexString(b & 0xFF); |
| | | //由于十六进制是由0~9、A~F来表示1~16,所以如果Byte转换成Hex后如果是<16,就会是一个字符(比如A=10),通常是使用两个字符来表示16进制位的, |
| | | //假如一个字符的话,遇到字符串11,这到底是1个字节,还是1和1两个字节,容易混淆,如果是补0,那么1和1补充后就是0101,11就表示纯粹的11 |
| | | if (hexString.length() < 2) |
| | | { |
| | | hexString = new StringBuilder(String.valueOf(0)).append(hexString).toString(); |
| | | } |
| | | return hexString.toUpperCase(); |
| | | } |
| | | } |