Android examples for java.lang:Byte Array
Convert byte array To Hex String via bit and 0xFF
import android.annotation.SuppressLint; import java.io.UnsupportedEncodingException; import java.util.regex.Pattern; public class Main{ public static String bytesToHexString(byte[] bytes) { StringBuilder sb = new StringBuilder(""); if (bytes == null || bytes.length <= 0) { return null; }/*from w ww. j a va 2s . c om*/ for (int i = 0; i < bytes.length; i++) { int v = bytes[i] & 0xFF; String hv = Integer.toHexString(v); if (hv.length() < 2) { sb.append(0); } sb.append(hv); } return sb.toString(); } }