Android Byte Array to Hex Convert toHex(byte[] bytes)

Here you can find the source of toHex(byte[] bytes)

Description

to Hex

License

Apache License

Declaration

public static final String toHex(byte[] bytes) 

Method Source Code

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

public class Main {
    private static final char[] hexDigits = "0123456789abcdef"
            .toCharArray();/* w ww  . j  a va2  s . c o m*/

    public static final String toHex(byte[] bytes) {
        StringBuilder sb = new StringBuilder(2 * bytes.length);
        for (byte b : bytes) {
            sb.append(hexDigits[(b >> 4) & 0xf]).append(hexDigits[b & 0xf]);
        }
        return sb.toString();
    }
}

Related

  1. Convert2bytesHexaFormatToInt(byte[] ArrayToConvert)
  2. ConvertHexByteArrayToString( byte[] byteArrayToConvert)
  3. toHex(byte[] array)
  4. toHex(byte[] array, int offset, int len)
  5. toHex(byte[] buf)
  6. toHex(byte[] bytes)
  7. toHex(byte[] bytes, String separator)
  8. toHex(byte[] bytes, int offset, int length)
  9. toHex(byte[] bytes, int offset, int length, String separator)