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

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

Description

Converts a byte array to a hex string.

License

Open Source License

Parameter

Parameter Description
bytes - a byte array

Return

a hex string

Declaration

public static String bytesToHexString(byte bytes[]) 

Method Source Code

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

public class Main {
    /**//from  ww w. j  a v a 2s.  com
     * Converts a byte array to a hex string.
     * 
     * @param bytes - a byte array
     * @return a hex string
     */
    public static String bytesToHexString(byte bytes[]) {
        StringBuilder sb = new StringBuilder();

        for (byte b : bytes)
            sb.append(String.format("%02x", b));

        return sb.toString();
    }
}

Related

  1. bytesToHexStr(byte[] bcd)
  2. bytesToHexStr(byte[] bytes)
  3. bytesToHexStr(byte[] bytes, int offset, int size)
  4. bytesToHexString(byte abyte0[])
  5. bytesToHexString(byte abyte0[], int i, int j)
  6. bytesToHexString(byte data[])
  7. bytesToHexString(byte[] _bytes)
  8. bytesToHexString(byte[] array)
  9. bytesToHexString(byte[] b)