MCPcopy Create free account
hub / github.com/ZTFtrue/My-note / hexStrToByteArrs

Method hexStrToByteArrs

java/SendHexDataByUDP.java:64–78  ·  view source on GitHub ↗

将十六进制的字符串转换成字节数组 @param hexString 字符串 @return 字节

(String hexString)

Source from the content-addressed store, hash-verified

62 * @return 字节
63 */
64 public static byte[] hexStrToByteArrs(String hexString) /* throws NullPointerException */ {
65 if (TextUtils.isEmpty(hexString)) {
66 throw new NullPointerException("字符串为空");
67 }
68 hexString = hexString.replaceAll(" ", "");
69 int len = hexString.length();
70 int index = 0;
71 byte[] bytes = new byte[len / 2];
72 while (index < len) {
73 String sub = hexString.substring(index, index + 2);
74 bytes[index / 2] = (byte) Integer.parseInt(sub, 16);
75 index += 2;
76 }
77 return bytes;
78 }
79}

Callers 1

sendDataMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected