字节数组转换为十六进制字符串 @param b byte[] 需要转换的字节数组 @return String 十六进制字符串
(byte b[])
| 591 | * @return String 十六进制字符串 |
| 592 | */ |
| 593 | public static String byteToHex(byte b[]) { |
| 594 | if (b == null) { |
| 595 | throw new IllegalArgumentException( |
| 596 | "Argument b ( byte array ) is null! "); |
| 597 | } |
| 598 | String hs = ""; |
| 599 | String stmp = ""; |
| 600 | for (int n = 0; n < b.length; n++) { |
| 601 | stmp = Integer.toHexString(b[n] & 0xff); |
| 602 | if (stmp.length() == 1) { |
| 603 | hs = hs + "0" + stmp; |
| 604 | } else { |
| 605 | hs = hs + stmp; |
| 606 | } |
| 607 | } |
| 608 | return hs.toLowerCase(); |
| 609 | //return hs.toUpperCase(); |
| 610 | } |
| 611 | |
| 612 | public static byte[] subByte(byte[] input, int startIndex, int length) { |
| 613 | byte[] bt = new byte[length]; |
no outgoing calls
no test coverage detected