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

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

Description

byte Arr Hex Str

Declaration

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

Method Source Code

//package com.java2s;

public class Main {

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

Related

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