Java Hex Calculate toHex(byte[] bytes)

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

Description

to Hex

License

Open Source License

Declaration

public static String toHex(byte[] bytes) 

Method Source Code

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

public class Main {
    public final static char[] HEX_VALUES = "0123456789ABCDEF".toCharArray();

    public static String toHex(byte[] bytes) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < bytes.length; i++) {
            byte b = bytes[i];
            int fnibble = (b >> 4);
            int snibble = 0x0f & b;
            buf.append(HEX_VALUES[fnibble]);
            buf.append(HEX_VALUES[snibble]);
        }// www  . j a v  a  2s . c o  m
        return buf.toString();
    }
}

Related

  1. toHEX(byte[] ba)
  2. toHex(byte[] buffer)
  3. toHex(byte[] buffer)
  4. toHex(byte[] bytes)
  5. toHex(byte[] bytes)
  6. toHex(byte[] bytes)
  7. toHex(byte[] bytes)
  8. toHex(byte[] bytes)
  9. toHex(byte[] bytes)