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

Method bytesToHex

src/main/java/Util.java:60–70  ·  view source on GitHub ↗

字节数组转16进制 @param bytes 需要转换的byte数组 @return 转换后的Hex字符串

(byte[] bytes)

Source from the content-addressed store, hash-verified

58 * @return 转换后的Hex字符串
59 */
60 public static String bytesToHex(byte[] bytes) {
61 StringBuffer sb = new StringBuffer();
62 for(int i = 0; i < bytes.length; i++) {
63 String hex = Integer.toHexString(bytes[i] & 0xFF);
64 if(hex.length() < 2){
65 sb.append(0);
66 }
67 sb.append(hex);
68 }
69 return sb.toString();
70 }
71
72 /**
73 * hex字符串转byte数组

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected