Java Hex Calculate toHexString(byte[] data)

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

Description

Returns the specified data as hex sequence

License

Apache License

Parameter

Parameter Description
data The data

Return

a hex string

Declaration

public static String toHexString(byte[] data) 

Method Source Code

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

public class Main {
    /**//from w w w. ja va 2  s . c  o m
     * Returns the specified data as hex sequence
     *
     * @param data
     *            The data
     * @return a hex string
     */
    public static String toHexString(byte[] data) {
        final int n = data.length;
        final StringBuilder hex = new StringBuilder();

        for (int i = 0; i < n; i++) {
            final byte b = data[i];
            hex.append(String.format("%02x", b & 0xff));
        }

        return hex.toString();
    }
}

Related

  1. toHexString(byte[] coded)
  2. toHexString(byte[] color)
  3. toHexString(byte[] content, int len)
  4. toHexString(byte[] data)
  5. toHexString(byte[] data)
  6. toHexString(byte[] data)
  7. toHexString(byte[] data)
  8. toHexString(byte[] data)
  9. toHexString(byte[] data)