Java Byte Array to Hex bytes2HexString(byte[] b)

Here you can find the source of bytes2HexString(byte[] b)

Description

bytes Hex String

License

Apache License

Declaration

static String bytes2HexString(byte[] b) 

Method Source Code

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

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

    static String bytes2HexString(byte[] b) {
        StringBuilder sb = new StringBuilder(b.length << 2);
        for (byte x : b) {
            int hi = (x & 0xf0) >> 4;
            int lo = x & 0x0f;
            sb.append(HEX_CHARS[hi]);// w  w w. ja  v a  2  s.  co m
            sb.append(HEX_CHARS[lo]);
        }
        return sb.toString();
    }
}

Related

  1. bytes2HexStr(byte[] bytes)
  2. bytes2HexString(byte... bytes)
  3. bytes2HexString(byte[] array)
  4. bytes2HexString(byte[] b)
  5. bytes2HexString(byte[] b)
  6. bytes2HexString(byte[] bytes)
  7. bytes2HexString(byte[] bytes)
  8. bytes2HexString(byte[] bytes)
  9. bytes2HexString(byte[] bytes)