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

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

Description

byte Array To Hex String

Declaration


public static String byteArrayToHexString(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    private static final String hexDigits = "0123456789abcdef";

    public static String byteArrayToHexString(byte[] b) {
        StringBuffer buf = new StringBuffer();

        for (int i = 0; i < b.length; i++) {
            int j = b[i] & 0xFF;
            buf.append(hexDigits.charAt(j / 16));
            buf.append(hexDigits.charAt(j % 16));
        }//w ww.  j  av a2  s .c o m

        return buf.toString();
    }
}

Related

  1. byte2hex(byte[] b)
  2. bytesToHexString(byte[] bytes)
  3. hex2byte(byte[] b)
  4. toHex(byte[] buf)
  5. toHex(byte[] data)