Java Byte Array to Hex String bytesToHexString(byte[] buf)

Here you can find the source of bytesToHexString(byte[] buf)

Description

bytes To Hex String

License

Apache License

Declaration

public static String bytesToHexString(byte[] buf) 

Method Source Code

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

public class Main {
    public static String bytesToHexString(byte[] buf) {
        final String decimals = "0123456789ABCDEF";
        if (buf == null)
            return null;
        char[] r = new char[buf.length * 2];
        for (int i = 0; i < buf.length; ++i) {
            r[i * 2] = decimals.charAt((buf[i] & 0xf0) >> 4);
            r[i * 2 + 1] = decimals.charAt(buf[i] & 0x0f);
        }//from w w  w.ja v a 2s  .c  om
        return new String(r);
    }
}

Related

  1. bytesToHexString(byte[] b)
  2. bytesToHexString(byte[] b, int length)
  3. bytesToHexString(byte[] bArray)
  4. bytesToHexString(byte[] bArray)
  5. bytesToHexString(byte[] bs)
  6. bytesToHexString(byte[] byteArray)
  7. bytesToHexString(byte[] bytes)
  8. bytesToHexString(byte[] bytes)
  9. bytesToHexString(byte[] bytes)