Java Byte Array to Hex String bytesToHexString(byte[] data)

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

Description

bytes To Hex String

License

Apache License

Declaration

public static final String bytesToHexString(byte[] data) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static final String bytesToHexString(byte[] data) {
        StringBuilder valueHex = new StringBuilder();
        for (int i = 0, tmp; i < data.length; i++) {
            tmp = data[i] & 0xff;/*from  w ww.j a  va  2 s . c o m*/
            if (tmp < 16) {
                valueHex.append(0);
            }
            valueHex.append(Integer.toHexString(tmp));
        }
        return valueHex.toString();
    }
}

Related

  1. bytesToHexString(byte[] bytes)
  2. bytesToHexString(byte[] bytes)
  3. bytesToHexString(byte[] bytes)
  4. bytesToHexString(byte[] bytes)
  5. bytesToHexString(byte[] data)
  6. bytesToHexString(byte[] data, int fromIndex, int toIndex)
  7. bytesToHexString(byte[] data, int offset, int length)
  8. bytesToHexString(byte[] hasher)
  9. bytesToHexString(byte[] in, int length)