Java Hex Calculate toHexString(byte[] bytes)

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

Description

Convert a set of bytes into a hexadecimal string.

License

Open Source License

Parameter

Parameter Description
bytes byte array to convert

Return

a Hexadecimal string representation of the bytes passed in.

Declaration

public static String toHexString(byte[] bytes) 

Method Source Code

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

public class Main {
    /**/*from w  w w  .  ja  va2 s  .  c o m*/
     * Convert a set of bytes into a hexadecimal string. Useful for storing MD5's as strings.
     * @param bytes byte array to convert
     * @return a Hexadecimal string representation of the bytes passed in.
     */
    public static String toHexString(byte[] bytes) {
        StringBuilder sb = new StringBuilder();
        for (byte aByte : bytes) {
            sb.append(Integer.toHexString(0xff & aByte));
        }
        return sb.toString();
    }
}

Related

  1. toHexString(byte[] bytes)
  2. toHexString(byte[] bytes)
  3. toHexString(byte[] bytes)
  4. toHexString(byte[] bytes)
  5. toHexString(byte[] bytes)
  6. toHexString(byte[] bytes)
  7. toHexString(byte[] bytes)
  8. toHexString(byte[] bytes)
  9. toHexString(byte[] bytes)