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

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

Description

convert To Hex

Declaration

private static String convertToHex(byte[] data) 

Method Source Code

//package com.java2s;

public class Main {
    private static String convertToHex(byte[] data) {
        StringBuilder buf = new StringBuilder();
        for (byte b : data) {
            int halfbyte = (b >>> 4) & 0x0F;
            int two_halfs = 0;
            do {/*from ww w  . j a va  2 s .  com*/
                buf.append((0 <= halfbyte) && (halfbyte <= 9) ? (char) ('0' + halfbyte)
                        : (char) ('a' + (halfbyte - 10)));
                halfbyte = b & 0x0F;
            } while (two_halfs++ < 1);
        }
        return buf.toString();
    }
}

Related

  1. bytesToHexString(byte[] src)
  2. ConvertHexString(byte[] b)
  3. getHexStringOfByte(byte[] bytes)
  4. bytesToHexString(byte[] bytes)
  5. bytesToHexString(byte[] bytes)
  6. toHex(final byte[] bytes)
  7. byteArrayToHexString(byte[] b)
  8. toHexString(byte abyte0[], int beginIndex, int endIndex, boolean spaceFlag)
  9. toHexString(byte abyte0[], int beginIndex, int endIndex)