Android examples for java.lang:Byte Array
Convert byte array to hex string using Integer.toHexString
import android.util.Base64; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; import java.util.Vector; import java.util.regex.Pattern; public class Main{ /**/* w ww . ja v a 2s . c om*/ * Convert byte[] to hex string. */ public static String bytes2HexString(byte[] data) { String ret = ""; for (int i = 0; i < data.length; i++) { String hex = Integer.toHexString(data[i] & 0xFF); if (hex.length() == 1) { hex = '0' + hex; } ret += hex.toUpperCase(); } return ret; } }