Android Byte Array to Hex Convert bytesToHexString(byte[] bytes)

Here you can find the source of bytesToHexString(byte[] bytes)

Description

bytes To Hex String

Declaration

public static String bytesToHexString(byte[] bytes) 

Method Source Code

//package com.java2s;

public class Main {
    public static String bytesToHexString(byte[] bytes) {
        if (bytes == null)
            return null;

        StringBuilder ret = new StringBuilder(2 * bytes.length);

        for (int i = 0; i < bytes.length; i++) {
            int b;

            b = 0x0f & (bytes[i] >> 4);

            ret.append("0123456789abcdef".charAt(b));

            b = 0x0f & bytes[i];/*from  w  w w.j  a  va  2 s  .  c  o  m*/

            ret.append("0123456789abcdef".charAt(b));
        }

        return ret.toString();
    }
}

Related

  1. bytesToHex(byte[] data)
  2. bytesToHex(byte[] data, int offset, int length)
  3. bytesToHexString(byte[] bytes)
  4. bytesToHexString(byte[] bytes)
  5. bytesToHexString(byte[] bytes)
  6. byte2HexStr(byte[] b)
  7. byte2HexStr(byte[] b, int length)
  8. byte2HexString(byte[] b)
  9. byte2Hext(byte bin)