Java Formatter Usage createHexadecimalString(byte[] data)

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

Description

Creates the hexadecimal string encoding specified data.

License

Open Source License

Parameter

Parameter Description
data The data to encode to hexadecimal string.

Return

The hexadecimal string representing data.

Declaration

public static String createHexadecimalString(byte[] data) 

Method Source Code

//package com.java2s;

import java.util.Formatter;

public class Main {
    /**/* w  w w .  j ava 2s  .  c  o m*/
     * Creates the hexadecimal string encoding specified data.
     * 
     * @param data
     *            The data to encode to hexadecimal string.
     * @return The hexadecimal string representing data.
     */
    public static String createHexadecimalString(byte[] data) {
        StringBuilder sb = new StringBuilder(data.length * 2);

        Formatter formatter = new Formatter(sb);
        for (byte b : data) {
            formatter.format("%02x", b);
        }
        formatter.close();

        return sb.toString();
    }
}

Related

  1. byteToHexWithPrefix(final byte[] data)
  2. chatting(String fmt, Object... args)
  3. convertRGBDecToHex(String decimal)
  4. convertTimeToString(double d, String timeFormat)
  5. convertToMillions(double tmp)
  6. digestToString(byte[] input)
  7. displayStackTrace()
  8. echo(Formatter script, String label, String message, String file)
  9. encodeHex(byte[] bytes)