Java Byte Array to Hex bytesToHex(byte[] data, int m, int n)

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

Description

bytes To Hex

License

Open Source License

Declaration

public static String bytesToHex(byte[] data, int m, int n) 

Method Source Code

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

public class Main {
    public static String bytesToHex(byte[] data, int m, int n) {
        char hexDigits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
        char[] temp = new char[n * 2];
        int k = m + n;
        for (int l = m; l < k; l++) {
            byte b = data[l];
            temp[l * 2] = hexDigits[b >>> 4 & 0x0f];
            temp[l * 2 + 1] = hexDigits[b & 0x0f];
        }/*  w  w  w  . ja  v  a 2  s. c  om*/
        return new String(temp);
    }

    public static String bytesToHex(byte[] data) {
        return bytesToHex(data, 0, data.length);
    }
}

Related

  1. bytesToHex(byte[] data)
  2. bytesToHex(byte[] data)
  3. bytesToHex(byte[] data)
  4. bytesToHex(byte[] data)
  5. bytesToHex(byte[] data, char[] chars)
  6. bytesToHex(byte[] digest)
  7. bytesToHex(byte[] in)
  8. bytesToHex(byte[] raw)
  9. bytesToHex(byte[] raw)