jiazx0107@163.com
2023-05-17 620eab6cca2bc9ef9ea6d3067a0a5ba1deadbd1c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.ld.igds.weather;
 
/**
 * @Desc:
 * @author: andy.jia
 * @update-time: 2023/4/23 19:26
 */
public class ServerUtils {
 
    public static final String MSG_START = "AABB";
    public static final String MSG_END = "EEEE";
 
 
    public static String getServerKey(String ip, int port) {
        return ip + ":" + port;
    }
 
 
    /**
     * 十六进制串转字节数组
     *
     * @param hexStr
     * @return
     */
    public static byte[] hexStrToBytes(String hexStr) {
        int size = hexStr.length() / 2;
        byte[] bytes = new byte[size];
        for (int i = 0; i < size; i++) {
            String tmp = hexStr.substring(i * 2, (i + 1) * 2);
            Integer tmpHex = Integer.parseInt(tmp, 16);
            bytes[i] = tmpHex.byteValue();
        }
        return bytes;
    }
}