Java Hex Calculate toHex(byte[] b)

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

Description

to Hex

License

Apache License

Declaration

public static String toHex(byte[] b) 

Method Source Code

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

public class Main {

    public static String toHex(byte[] b) {
        StringBuilder buffer = new StringBuilder(128);
        for (byte i : b) {
            buffer.append(toHex(i));/*from  w  w  w .j  a  v a 2s  .  c o m*/
        }
        return buffer.toString();
    }

    public static char[] toHex(byte in) {
        char[] out = new char[2];
        int h = 0;
        h = in >> 4 & 0xF;
        out[0] = (char) (h > 9 ? h + 0x37 : h + 0x30);
        h = in & 0xF;
        out[1] = (char) (h > 9 ? h + 0x37 : h + 0x30);
        return out;
    }
}

Related

  1. tohex(byte[] arg)
  2. toHex(byte[] arr)
  3. toHex(byte[] array)
  4. toHex(byte[] array, int offset, int length)
  5. toHex(byte[] b)
  6. toHex(byte[] b)
  7. toHex(byte[] b)
  8. toHex(byte[] b)
  9. toHex(byte[] b, int off, int len, String separator)