Android Byte Array to Hex Convert byteArr2HexStr(byte[] arrB)

Here you can find the source of byteArr2HexStr(byte[] arrB)

Description

byte Arr Hex Str

Declaration

public static String byteArr2HexStr(byte[] arrB) throws Exception 

Method Source Code

//package com.java2s;

public class Main {
    public static String byteArr2HexStr(byte[] arrB) throws Exception {
        int iLen = arrB.length; 
        StringBuffer sb = new StringBuffer(iLen * 2);
        for (int i = 0; i < iLen; i++) {
            int intTmp = arrB[i];
            while (intTmp < 0) {
                intTmp = intTmp + 256;//w w w.  j a  va 2s  .c o m
            }
            if (intTmp < 16) {
                sb.append("0");
            }
            sb.append(Integer.toString(intTmp, 16));
        }
        return sb.toString();
    }
}

Related

  1. byte2HexStr(byte[] b)
  2. byte2HexStr(byte[] b, int length)
  3. byte2HexString(byte[] b)
  4. byte2Hext(byte bin)
  5. byteArr2HexStr(byte[] arr)
  6. byteArr2HexStr(byte[] paramArrayOfByte)
  7. byteArray2HexString(byte[] data)
  8. Convert2bytesHexaFormatToInt(byte[] ArrayToConvert)
  9. ConvertHexByteArrayToString( byte[] byteArrayToConvert)