String to Hex : Hex « Date Type « Android






String to Hex

 

 class StringUtils {

    public static String toHex(byte[] response) {
        StringBuilder builder = new StringBuilder();
        builder.append("0x");
        for (byte b : response) {
            builder.append(String.format("%02x", b));
        }
        return builder.toString();
    }

}

   
  








Related examples in the same category

1.Hex Dump
2.converts given byte array to a hex string
3.converts given hex string to a byte array (ex: "0D0A" => {0x0D, 0x0A,})
4.Color name and its hex value
5.hex To Decimal
6.Get Hex string out of byte array
7.get Brightness, get Hex Name
8.Convenience method to convert a byte to a hex string.
9.Convenience method to convert a byte array to a hex string.
10.Convert a byte[] array to readable string format. This makes the "hex" readable!
11.Decode Unicode Hex
12.byte Array To Hex String