Java Byte to Hex String byteToHexstr(byte[] b, boolean space)

Here you can find the source of byteToHexstr(byte[] b, boolean space)

Description

byte To Hexstr

License

Open Source License

Declaration

public static String byteToHexstr(byte[] b, boolean space) 

Method Source Code

//package com.java2s;

public class Main {

    public static String byteToHexstr(byte[] b, boolean space) {
        StringBuilder toHex = new StringBuilder();

        for (int i = 0; (null != b) && (i < b.length); i++) {
            if (space) {
                toHex.append(' ');
            }//from www .ja  v  a 2  s  .  c  o  m

            char hi = Character.forDigit((b[i] >> 4) & 0x0F, 16);
            char lo = Character.forDigit(b[i] & 0x0F, 16);
            toHex.append(Character.toUpperCase(hi));
            toHex.append(Character.toUpperCase(lo));

        }

        return toHex.toString();
    }
}

Related

  1. byteToHexStr(byte b)
  2. byteToHexStr(byte b)
  3. byteToHexStr(byte buf[])
  4. byteToHexStr(byte src, int len, int code)
  5. byteToHexStr(byte[] bArray)
  6. byteToHexString(byte _b)
  7. byteToHexString(byte b)
  8. byteToHexString(byte b)