Java Hex Calculate toHex(byte[] value)

Here you can find the source of toHex(byte[] value)

Description

to Hex

License

Apache License

Declaration

public static String toHex(byte[] value) 

Method Source Code

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

public class Main {
    private static final char[] hex = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c',
            'd', 'e', 'f' };

    public static String toHex(byte[] value) {
        final StringBuilder b = new StringBuilder();

        for (byte c : value)
            b.append(hex[(c >>> 4) & 0xf]).append(hex[c & 0xf]);

        return "0x" + b.toString();
    }//from   w  w  w  .  j av a 2 s  .  co  m
}

Related

  1. toHex(byte[] src)
  2. toHex(byte[] text)
  3. toHex(byte[] v)
  4. toHex(byte[] val)
  5. toHex(byte[] val, int start, int len)
  6. toHex(byte[] value)
  7. toHex(char c)
  8. toHex(final byte b)
  9. toHex(final byte b)