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

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

Description

bytes To Hex

Declaration

public static String bytesToHex(byte[] data) 

Method Source Code

//package com.java2s;

public class Main {
    public static String bytesToHex(byte[] data) {
        return bytesToHex(data, 0, data.length);
    }/*from   w w  w  . j ava2 s  . c o m*/

    public static String bytesToHex(byte[] data, int offset, int length) {
        if (length <= 0) {
            return "";
        }

        StringBuilder hex = new StringBuilder();
        for (int i = offset; i < offset + length; i++) {
            hex.append(String.format(" %02X", data[i] % 0xFF));
        }
        hex.deleteCharAt(0);
        return hex.toString();
    }
}

Related

  1. bytes2Hex(byte[] bts)
  2. bytes2HexString(byte[] bytes)
  3. bytes2hex(byte[] bytes)
  4. bytesToHex(byte[] bytes)
  5. bytesToHex(byte[] data)
  6. bytesToHex(byte[] data, int offset, int length)
  7. bytesToHexString(byte[] bytes)
  8. bytesToHexString(byte[] bytes)
  9. bytesToHexString(byte[] bytes)