FileDocCategorySizeDatePackage
Hex.javaAPI Docmp4parser 1.0-RC-172026Wed Dec 19 20:10:38 GMT 2012com.coremedia.iso

Hex

public class Hex extends Object
Converts hexadecimal Strings.

Fields Summary
private static final char[]
DIGITS
Constructors Summary
Methods Summary
public static byte[]decodeHex(java.lang.String hexString)

        ByteArrayOutputStream bas = new ByteArrayOutputStream();
        for (int i = 0; i < hexString.length(); i += 2) {
            int b = Integer.parseInt(hexString.substring(i, i + 2), 16);
            bas.write(b);
        }
        return bas.toByteArray();
    
public static java.lang.StringencodeHex(byte[] data)


         
        return encodeHex(data, 0);
    
public static java.lang.StringencodeHex(byte[] data, int group)

        int l = data.length;
        char[] out = new char[(l << 1) + (group > 0 ? (l / group) : 0)];
        // two characters form the hex value.
        for (int i = 0, j = 0; i < l; i++) {
            if ((group > 0) && ((i % group) == 0) && j > 0) {
                out[j++] = '-";
            }

            out[j++] = DIGITS[(0xF0 & data[i]) >>> 4];
            out[j++] = DIGITS[0x0F & data[i]];
        }
        return new String(out);