Android Byte Array to Hex Convert bytesToHex(byte[] data, int offset, int length)

Here you can find the source of bytesToHex(byte[] data, int offset, int length)

Description

bytes To Hex

Declaration

public static String bytesToHex(byte[] data, int offset, int length) 

Method Source Code

//package com.java2s;

public class Main {
    public static String bytesToHex(byte[] data) {
        return bytesToHex(data, 0, data.length);
    }//w  ww. j  av  a 2 s  . c om

    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. bytes2HexString(byte[] bytes)
  2. bytes2hex(byte[] bytes)
  3. bytesToHex(byte[] bytes)
  4. bytesToHex(byte[] data)
  5. bytesToHex(byte[] data)
  6. bytesToHexString(byte[] bytes)
  7. bytesToHexString(byte[] bytes)
  8. bytesToHexString(byte[] bytes)
  9. bytesToHexString(byte[] bytes)