Byte[] 轉 16 進制

/**
     * Byte[] 轉 16 進制
     * @param buffer
     * @return
     */
    public static String byte2hex(byte[] buffer) {

        String hs = "";
        String stmp = "";

        for (int n = 0; n < buffer.length; n++) {
            stmp = (java.lang.Integer.toHexString(buffer[n] & 0XFF));

            if (stmp.length() == 1) {
                hs = hs + "0" + stmp;
            }
            else {
                hs = hs + stmp;
            }
        }

        return hs.toUpperCase();
    }
相關文章
相關標籤/搜索