Java Hex Calculate toHexString(byte[] b)

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

Description

Return hex string of bytes.

License

Academic Free License

Declaration

public static String toHexString(byte[] b) 

Method Source Code

//package com.java2s;
// Licensed under the Academic Free License version 3.0

public class Main {
    /**/*from   w  w w . j  a  v  a 2  s  .c o  m*/
     * Return hex string of bytes.
     */
    public static String toHexString(byte[] b) {
        StringBuffer s = new StringBuffer();
        for (int i = 0; i < b.length; ++i)
            s.append(byteToHexString(b[i]));
        return s.toString();
    }

    /**
     * @return byte to two character hex string.
     */
    public static String byteToHexString(int b) {
        String s = Integer.toHexString(b & 0xFF);

        if (s.length() == 1)
            return "0" + s;
        else
            return s;
    }
}

Related

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