回覆列表
  • 1 # 影片好笑

    byte陣列轉換成16進位制字串String:public class CommonUtil {/*** byte陣列轉換成16進位制字串* @param src* @return*/public static String bytesToHexString(byte[] src){StringBuilder stringBuilder = new StringBuilder();if (src == null || src.length <= 0) {return null;}for (int i = 0; i < src.length; i++) {int v = src[i] & 0xFF;String hv = Integer.toHexString(v);if (hv.length() < 2) {stringBuilder.append(0);}stringBuilder.append(hv);}return stringBuilder.toString();}}byte陣列轉換成16進位制字元陣列String[]:public class CommonUtil {/*** byte陣列轉換成16進位制字元陣列* @param src* @return*/public static String[] bytesToHexStrings(byte[] src){if (src == null || src.length <= 0) {return null;}String[] str = new String[src.length];for (int i = 0; i < src.length; i++) {int v = src[i] & 0xFF;String hv = Integer.toHexString(v);if (hv.length() < 2) {str[i] = "0";}str[i] = hv;}return str;}}

  • 中秋節和大豐收的關聯?
  • 黃河之水天上來,下一句是什麼?