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

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

Description

hex To Hex String

Parameter

Parameter Description
b a parameter

Declaration

public static String hexToHexString(byte[] b) 

Method Source Code

//package com.java2s;
import java.util.Locale;

public class Main {
    /**/*from   w  w w.  j  av  a  2 s.  c  om*/
     * 
     * @param b
     * @return
     */
    public static String hexToHexString(byte[] b) {
        int len = b.length;
        int[] x = new int[len];
        String[] y = new String[len];
        StringBuilder str = new StringBuilder();
        int j = 0;
        for (; j < len; j++) {
            x[j] = b[j] & 0xff;
            y[j] = Integer.toHexString(x[j]);
            while (y[j].length() < 2) {
                y[j] = "0" + y[j];
            }
            str.append(y[j]);
            str.append("");
        }
        return new String(str).toUpperCase(Locale.getDefault());
    }
}

Related

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