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

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

Description

bytes To Hex String

License

Open Source License

Declaration

public static String bytesToHexString(byte[] src) 

Method Source Code

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

public class Main {

    public static String bytesToHexString(byte[] src) {
        if (src == null || src.length <= 0) {
            return "";
        }//from w  w  w. ja v  a  2  s  . c om
        StringBuilder stringBuilder = new StringBuilder("");
        for (int i = 0; i < src.length; i++) {
            String hv = Integer.toHexString(src[i] & 0xFF);
            if (hv.length() < 2) {
                stringBuilder.append(0);
            }
            stringBuilder.append(hv);
        }
        return stringBuilder.toString();
    }
}

Related

  1. bytesToHexString(byte[] hasher)
  2. bytesToHexString(byte[] in, int length)
  3. bytesToHexString(byte[] input)
  4. bytesToHexString(byte[] mpi)
  5. bytesToHexString(byte[] src)
  6. bytesToHexString(final byte[] bytes)
  7. bytesToHexString(final byte[] bytes)
  8. bytesToHexString(final byte[] bytes)
  9. bytesToHexString(final byte[] bytes)