Java Byte Array to Hex bytesToHex(byte[] buf)

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

Description

bytes To Hex

License

Open Source License

Declaration

public static String bytesToHex(byte[] buf) 

Method Source Code

//package com.java2s;

public class Main {
    public static String bytesToHex(byte[] buf) {
        final StringBuilder b = new StringBuilder(buf.length * 2);

        for (int i = 0; i < buf.length; i++) {
            final int cell = (int) (buf[i] & 0xFF);
            if (cell < 16) {
                b.append("0");
            }/* w  ww . ja va 2  s.  c o  m*/

            b.append(Integer.toString(cell, 16));
        }

        return b.toString();
    }
}

Related

  1. bytesToHex(byte[] b)
  2. bytesToHex(byte[] b, int offset, int length)
  3. bytesToHex(byte[] binary)
  4. bytesToHex(byte[] bs, int off, int length)
  5. bytesToHex(byte[] bt)
  6. bytesToHex(byte[] bytes)
  7. bytesToHex(byte[] bytes)
  8. bytesToHex(byte[] bytes)
  9. bytesToHex(byte[] bytes)