Android examples for java.lang:Hex
Convert byte Array To Hex String using bit and
import java.util.Locale; public class Main{ public static final String byteArrayToHexString(byte[] data) { StringBuilder sb = new StringBuilder(data.length * 2); for (byte b : data) { int v = b & 0xff; if (v < 16) { sb.append('0'); }/* w w w. java 2 s. c o m*/ sb.append(Integer.toHexString(v)); } return sb.toString().toUpperCase(Locale.getDefault()); } }