Java Byte to Hex String byteToHexString(byte[] b)

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

Description

byte To Hex String

License

Apache License

Declaration

public static String byteToHexString(byte[] b) 

Method Source Code

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

public class Main {
    private final static byte[] hex = "0123456789ABCDEF".getBytes();

    public static String byteToHexString(byte[] b) {
        byte[] buff = new byte[2 * b.length];
        for (int i = 0; i < b.length; i++) {
            buff[2 * i] = hex[(b[i] >> 4) & 0x0f];
            buff[2 * i + 1] = hex[b[i] & 0x0f];
        }//from w w w . j av  a 2s. c  o m
        return new String(buff);
    }
}

Related

  1. byteToHexString(byte num)
  2. byteToHexString(byte src)
  3. byteToHexString(byte value)
  4. byteToHexString(byte value)
  5. byteToHexString(byte[] b)
  6. byteToHexString(byte[] bytes)
  7. byteToHexString(byte[] bytes, int start, int end)
  8. byteToHexString(byte[] bytes, int start, int end)
  9. byteToHexString(byte[] data)