Android Byte Array to Hex Convert bytesToHex(byte[] data)

Here you can find the source of bytesToHex(byte[] data)

Description

bytes To Hex

Declaration

public static String bytesToHex(byte[] data) 

Method Source Code

//package com.java2s;

public class Main {
    public static String bytesToHex(byte[] data) {
        if (data == null) {
            return null;
        }//from   w  w w . j  a  v  a  2 s .c  o  m

        int len = data.length;
        String str = "";
        for (int i = 0; i < len; i++) {
            if ((data[i] & 0xFF) < 16)
                str = str + "0"
                        + java.lang.Integer.toHexString(data[i] & 0xFF);
            else
                str = str + java.lang.Integer.toHexString(data[i] & 0xFF);
        }
        return str;
    }
}

Related

  1. byte2hex(byte[] b)
  2. byte2hex(byte[] b)
  3. hexEncode(byte[] data)
  4. encodeHex(byte[] data)
  5. decodeHex(char[] data)
  6. bytesToHexString(byte[] bytesArray)
  7. parseByte2HexStr(byte buf[])
  8. bytesToHex(byte[] bytes)
  9. bytesToHex(byte[] bytes, boolean withSpaces)