MCPcopy Create free account
hub / github.com/Ape1ron/SpringAopInDeserializationDemo1 / hexToByteArray

Method hexToByteArray

src/main/java/Util.java:77–93  ·  view source on GitHub ↗

hex字符串转byte数组 @param hex 待转换的Hex字符串 @return 转换后的byte数组结果

(String hex)

Source from the content-addressed store, hash-verified

75 * @return 转换后的byte数组结果
76 */
77 public static byte[] hexToByteArray(String hex){
78 int hexlen = hex.length();
79 byte[] result;
80 if (hexlen % 2 == 1){
81 hexlen++;
82 result = new byte[(hexlen/2)];
83 hex="0"+hex;
84 }else {
85 result = new byte[(hexlen/2)];
86 }
87 int j=0;
88 for (int i = 0; i < hexlen; i+=2){
89 result[j]=(byte)Integer.parseInt(hex.substring(i,i+2),16);
90 j++;
91 }
92 return result;
93 }
94
95 public static String join(String[] strings, String sep, String prefix, String suffix) {
96 final StringBuilder sb = new StringBuilder();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected