Android Utililty Methods Hex String Create

List of utility methods to do Hex String Create

Description

The list of methods to do Hex String Create are organized into topic(s).

Method

StringbytesToHexString(byte[] bArray)
bytes To Hex String
StringBuffer sb = new StringBuffer(bArray.length);
for (int i = 0; i < bArray.length; i++) {
    String sTemp = Integer.toHexString(0xFF & bArray[i]);
    if (sTemp.length() < 2) {
        sb.append(0);
    sb.append(sTemp.toUpperCase());
return sb.toString();
StringmakeHex(int val)
make Hex
String ret = "";
String[] hexChars = new String[16];
for (int i = 0; i < 10; i++) {
    hexChars[i] = String.valueOf(i);
hexChars[10] = "A";
hexChars[11] = "B";
hexChars[12] = "C";
...
intmakeInt(String hex)
make Int
int ret = 0;
String[] hexChars = new String[16];
for (int i = 0; i < 10; i++) {
    hexChars[i] = String.valueOf(i);
hexChars[10] = "A";
hexChars[11] = "B";
hexChars[12] = "C";
...
voidappendHexJavaScriptRepresentation(int codePoint, Appendable out)
Returns a javascript representation of the character in a hex escaped format.
if (Character.isSupplementaryCodePoint(codePoint)) {
    char[] surrogates = Character.toChars(codePoint);
    appendHexJavaScriptRepresentation(surrogates[0], out);
    appendHexJavaScriptRepresentation(surrogates[1], out);
    return;
out.append("\\u").append(HEX_CHARS[(codePoint >>> 12) & 0xf])
        .append(HEX_CHARS[(codePoint >>> 8) & 0xf])
...
voidappendHexJavaScriptRepresentation(StringBuilder sb, char c)
Although this is a rather specific method, it is made public because it is also used by the JSCompiler.
try {
    appendHexJavaScriptRepresentation(c, sb);
} catch (IOException ex) {
    throw new RuntimeException(ex);
byte[]hexToBytes(CharSequence str)
Convert a string of hex digits to a byte array, with the first byte in the array being the MSB.
byte[] bytes = new byte[(str.length() + 1) / 2];
if (str.length() == 0) {
    return bytes;
bytes[0] = 0;
int nibbleIdx = (str.length() % 2);
for (int i = 0; i < str.length(); i++) {
    char c = str.charAt(i);
...
inthexValue(char c)
hex Value
if ((c >= '0') && (c <= '9')) {
    return (c - '0');
} else if ((c >= 'a') && (c <= 'f')) {
    return (c - 'a') + 10;
} else {
    return (c - 'A') + 10;
booleanisHex(char c)
is Hex
return ((c >= '0') && (c <= '9')) || ((c >= 'a') && (c <= 'f'))
        || ((c >= 'A') && (c <= 'F'));
StringgetHexString(int[] b)
get Hex String
return getHexString(b, HEX_STRING_BLANK_SPLIT);
StringgetHexString(int[] b, String splitString)
get Hex String
StringBuffer sb = new StringBuffer();
for (int c : b) {
    String strData = Integer.toHexString(c);
    if (strData.length() == 1) {
        sb.append("0").append(strData);
    } else {
        sb.append(strData);
    sb.append(splitString);
return sb.toString().trim();