Android examples for java.lang:Byte Array
Convert byte Array To Hex String with bit and
import java.util.Locale; public class Main{ public static String byteArrayToHexString(byte[] bytes) { StringBuffer sb = new StringBuffer(bytes.length * 2); byte[] var1 = bytes; int var2 = bytes.length; for (int i = 0; i < var2; ++i) { byte b = var1[i]; int v = b & 255; if (v < 16) { sb.append('0'); }//from w w w .j a v a 2 s . com sb.append(Integer.toHexString(v)); } return sb.toString().toUpperCase(Locale.getDefault()); } }