Android examples for java.lang:Hex
Convert byte Array To Hex String using String.format("%02x", b & 0xff)
public class Main{ @UsedForTesting/* w ww .j a va 2 s .co m*/ public static String byteArrayToHexString(byte[] bytes) { if (bytes == null || bytes.length == 0) { return ""; } final StringBuilder sb = new StringBuilder(); for (byte b : bytes) { sb.append(String.format("%02x", b & 0xff)); } return sb.toString(); } }