Android examples for java.lang:Byte Array
Convert byte Array To Hex String by converting byte to hex one by one
import android.text.TextUtils; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.util.AbstractCollection; import java.util.Collection; import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static String byteArrayToHexString(byte[] b) { StringBuffer resultSb = new StringBuffer(); for (int i = 0; i < b.length; i++) { resultSb.append(byteToHexString(b[i])); }//w w w .ja v a 2 s . c o m return resultSb.toString(); } private static String byteToHexString(byte b) { int n = b; if (n < 0) n = 256 + n; int d1 = n / 16; int d2 = n % 16; return hexDigits[d1] + hexDigits[d2]; } }