Android Utililty Methods String Decode

List of utility methods to do String Decode

Description

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

Method

byte[]decode(String base64)
decode
return Base64.decode(base64.getBytes(), Base64.DEFAULT);
Stringdecode(String source)
Returns the plaintext equivalent of a base 64-encoded string.
if (source.length() % 4 != 0)
    throw new RuntimeException(
            "valid Base64 codes have a multiple of 4 characters");
int numGroups = source.length() / 4;
int numExtraBytes = source.endsWith("==") ? 2 : (source
        .endsWith("=") ? 1 : 0);
byte[] targetBytes = new byte[3 * numGroups];
byte[] sourceBytes = new byte[4];
...
byte[]decode(String str)
Converts from String to byte array
return Base64.decode(str.getBytes(), Base64.DEFAULT);
byte[]decode(String str)
decode
byte[] data = str.getBytes();
int len = data.length;
ByteArrayOutputStream buf = new ByteArrayOutputStream(len);
int i = 0;
int b1, b2, b3, b4;
while (i < len) {
    do {
        b1 = base64DecodeChars[data[i++]];
...
byte[]decode(String s)
decode
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
    decode(s, bos);
} catch (IOException e) {
    throw new RuntimeException();
byte[] decodedBytes = bos.toByteArray();
try {
...
Stringdecode(String str)
decode
try {
    byte[] result = Base64.decode(str, Base64.DEFAULT);
    return new String(result);
} catch (Exception e) {
    return str;
byte[]decode(String base64)
decode
int pad = 0;
for (int i = base64.length() - 1; base64.charAt(i) == '='; i--) {
    pad++;
int length = (base64.length() * 6) / 8 - pad;
byte raw[] = new byte[length];
int rawindex = 0;
for (int i = 0; i < base64.length(); i += 4) {
...
voiddecodeYUV420SPQuarterRes(int[] rgb, byte[] yuv420sp, int width, int height)
decode YUVSP Quarter Res
final int frameSize = width * height;
for (int j = 0, ypd = 0; j < height; j += 4) {
    int uvp = frameSize + (j >> 1) * width, u = 0, v = 0;
    for (int i = 0; i < width; i += 4, ypd++) {
        int y = (0xff & (yuv420sp[j * width + i])) - 16;
        if (y < 0) {
            y = 0;
        if ((i & 1) == 0) {
            v = (0xff & yuv420sp[uvp++]) - 128;
            u = (0xff & yuv420sp[uvp++]) - 128;
            uvp += 2; 
        int y1192 = 1192 * y;
        int r = (y1192 + 1634 * v);
        int g = (y1192 - 833 * v - 400 * u);
        int b = (y1192 + 2066 * u);
        if (r < 0) {
            r = 0;
        } else if (r > 262143) {
            r = 262143;
        if (g < 0) {
            g = 0;
        } else if (g > 262143) {
            g = 262143;
        if (b < 0) {
            b = 0;
        } else if (b > 262143) {
            b = 262143;
        rgb[ypd] = 0xff000000 | ((r << 6) & 0xff0000)
                | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff);
Stringdecode(String s)
decode
StringBuffer stringbuffer = new StringBuffer();
int i = s.length();
byte byte0 = -1;
int l = 0;
int i1 = 0;
int j1 = -1;
for (; i1 < i; i1++) {
    int j;
...