Java Byte to Hex byteToHex(byte[] data)

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

Description

Converts the content of a byte array into a human readable form.

License

Open Source License

Parameter

Parameter Description
data The byte array to be converted.

Return

The hex converted byte array.

Declaration

public static String byteToHex(byte[] data) 

Method Source Code

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

public class Main {
    /**/* w w w .  j  a va 2  s.  c om*/
     * Converts the content of a byte array into a human readable form.
     * 
     * @param data The byte array to be converted.
     * @return The hex converted byte array.
     */
    public static String byteToHex(byte[] data) {
        StringBuilder sb = new StringBuilder();
        for (byte b : data) {
            sb.append(String.format("%02X", b));
        }
        return sb.toString();
    }
}

Related

  1. byteToHex(byte b, StringBuffer buf)
  2. byteToHex(byte bytevalue)
  3. ByteToHex(byte byyte)
  4. byteToHex(byte c)
  5. byteToHex(byte[] bytes)
  6. byteToHex(char val)
  7. byteToHex(final byte b)
  8. byteToHex(final byte b)
  9. byteToHex(final byte b, StringBuilder buffer)