Android Byte Array to Hex Convert toHexString(byte[] b)

Here you can find the source of toHexString(byte[] b)

Description

to Hex String

Declaration

private static String toHexString(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    private static String toHexString(byte[] b) { //String to  byte
        char HEX_DIGITS[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8',
                '9', 'A', 'B', 'C', 'D', 'E', 'F' };

        StringBuilder sb = new StringBuilder(b.length * 2);
        for (int i = 0; i < b.length; i++) {
            sb.append(HEX_DIGITS[(b[i] & 0xf0) >>> 4]);
            sb.append(HEX_DIGITS[b[i] & 0x0f]);
        }//  w  w  w . ja va  2 s  .co  m
        return sb.toString();
    }
}

Related

  1. getHexString(byte[] b)
  2. getHexString(byte[] b, String splitString)
  3. toHex(byte[] b)
  4. bytesToHexString(byte[] bytes)
  5. hexToHexString(byte[] b)
  6. bytesToHexString(byte[] src)
  7. ConvertHexString(byte[] b)
  8. getHexStringOfByte(byte[] bytes)
  9. bytesToHexString(byte[] bytes)