Java Hex Calculate toHex(byte data[])

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

Description

to Hex

License

Open Source License

Declaration

public static final String toHex(byte data[]) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final String toHex(byte data[]) {
        char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', };
        StringBuffer result = new StringBuffer(data.length * 2);

        for (int i = 0; i < data.length; i++) {
            result.append(hex[(data[i] >> 4) & 0x0f]).append(hex[data[i] & 0x0f]);
        }/*from   w w  w .  ja  va2  s  .  c  o m*/

        return result.toString();
    }
}

Related

  1. toHex(byte b)
  2. toHex(byte b)
  3. toHex(byte b, char[] charArray, int from)
  4. toHex(byte b, String prefix)
  5. toHex(byte bytes[])
  6. toHex(byte hash[])
  7. toHex(byte in)
  8. toHex(byte in[])
  9. toHex(byte in[])