From 8efb5a8cd2c8a6b40e58f4f3fb851d54cf415af9 Mon Sep 17 00:00:00 2001 From: jiazx0107@163.com <jiazx0107@163.com> Date: 星期日, 24 十二月 2023 01:23:55 +0800 Subject: [PATCH] 游仙协议解析-1 --- src/main/java/com/fzzy/api/utils/BytesUtil.java | 32 +++++++++----------------------- 1 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/fzzy/api/utils/BytesUtil.java b/src/main/java/com/fzzy/api/utils/BytesUtil.java index 37a1ee6..af4348e 100644 --- a/src/main/java/com/fzzy/api/utils/BytesUtil.java +++ b/src/main/java/com/fzzy/api/utils/BytesUtil.java @@ -320,29 +320,6 @@ return String.format("%04x", num).toUpperCase(); } - // 璁$畻16杩涘埗瀵瑰簲鐨勬暟鍊� - public static int GetHex(char ch) throws Exception { - if (ch >= '0' && ch <= '9') - return (int) (ch - '0'); - if (ch >= 'a' && ch <= 'f') - return (int) (ch - 'a' + 10); - if (ch >= 'A' && ch <= 'F') - return (int) (ch - 'A' + 10); - throw new Exception("error param"); - } - - // 璁$畻骞� - public static int GetPower(int nValue, int nCount) throws Exception { - if (nCount < 0) - throw new Exception("nCount can't small than 1!"); - if (nCount == 0) - return 1; - int nSum = 1; - for (int i = 0; i < nCount; ++i) { - nSum = nSum * nValue; - } - return nSum; - } public static void main(String[] args) { @@ -353,6 +330,7 @@ System.out.println(d2); System.out.println(d1 + d2); + } @@ -461,4 +439,12 @@ } return biannary2Decimal(two) + 1; } + + public static String byteToHex(byte b) { + String hex = Integer.toHexString(b & 0xFF); + if (hex.length() < 2) { + hex = "0" + hex; + } + return hex; + } } -- Gitblit v1.9.3