Android Byte Array to Hex Convert ConvertHexByteArrayToString( byte[] byteArrayToConvert)

Here you can find the source of ConvertHexByteArrayToString( byte[] byteArrayToConvert)

Description

Convert Hex Byte Array To String

License

Open Source License

Declaration

public static String ConvertHexByteArrayToString(
            byte[] byteArrayToConvert) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String ConvertHexByteArrayToString(
            byte[] byteArrayToConvert) {
        String ConvertedByte = "";
        for (int i = 0; i < byteArrayToConvert.length; i++) {
            if (byteArrayToConvert[i] < 0) {
                ConvertedByte += Integer.toString(
                        byteArrayToConvert[i] + 256, 16) + " ";
            } else if (byteArrayToConvert[i] <= 15) {
                ConvertedByte += "0"
                        + Integer.toString(byteArrayToConvert[i], 16) + " ";
            } else {
                ConvertedByte += Integer
                        .toString(byteArrayToConvert[i], 16) + " ";
            }// ww  w  .j av  a2  s.c  o  m
        }

        return ConvertedByte;
    }
}

Related

  1. byteArr2HexStr(byte[] arr)
  2. byteArr2HexStr(byte[] arrB)
  3. byteArr2HexStr(byte[] paramArrayOfByte)
  4. byteArray2HexString(byte[] data)
  5. Convert2bytesHexaFormatToInt(byte[] ArrayToConvert)
  6. toHex(byte[] array)
  7. toHex(byte[] array, int offset, int len)
  8. toHex(byte[] buf)
  9. toHex(byte[] bytes)