Java Byte to Hex String byteToHexStr(byte buf[])

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

Description

byte To Hex Str

License

Open Source License

Declaration

public static String byteToHexStr(byte buf[]) 

Method Source Code

//package com.java2s;

public class Main {

    public static String byteToHexStr(byte buf[]) {
        StringBuffer sb = new StringBuffer();

        for (int i = 0; i < buf.length; i++) {
            String hex = Integer.toHexString(buf[i] & 0xFF);

            if (hex.length() == 1) {
                hex = '0' + hex;
            }//from   www.ja v a  2s  .  c om

            sb.append(hex);
        }

        return sb.toString();
    }
}

Related

  1. byteToHexStr(byte b)
  2. byteToHexStr(byte b)
  3. byteToHexStr(byte src, int len, int code)
  4. byteToHexstr(byte[] b, boolean space)
  5. byteToHexStr(byte[] bArray)
  6. byteToHexString(byte _b)