Android Utililty Methods Base64 Decode

List of utility methods to do Base64 Decode

Description

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

Method

StringdecodeBase64(String value)
decode Base
if (!isEmpty(value)) {
    return new String(Base64.decode(value, Base64.DEFAULT));
return "";
StringdecodeBase64(String src)
decode Base
return new String(Base64.decode(src, Base64.DEFAULT));
byte[]decode(String base64)
decode
return Base64.decode(base64.getBytes(), Base64.DEFAULT);
byte[]decode(String data)
decode
ByteArrayOutputStream baos = new ByteArrayOutputStream(
        data.length());
try {
    decode(data, baos);
} catch (IOException ioe) {
    throw new IllegalStateException(ioe);
return baos.toByteArray();
...
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)
Decodes a BASE64 encoded string.
int length = s.length();
if (length == 0) {
    return new byte[0];
int sndx = 0, endx = length - 1;
int pad = s.charAt(endx) == '=' ? (s.charAt(endx - 1) == '=' ? 2
        : 1) : 0;
int cnt = endx - sndx + 1;
...
byte[]decode(String str)
decode
StringBuffer sb = new StringBuffer();
byte[] data = str.getBytes("US-ASCII");
int len = data.length;
int i = 0;
int b1, b2, b3, b4;
while (i < len) {
    do {
        b1 = DECODE_CHARS[data[i++]];
...
byte[]fromBase64(String data)
Decode a base64 string into a byte array.
if (data == null) {
    return null;
int len = data.length();
assert (len % 4) == 0;
if (len == 0) {
    return new byte[0];
char[] chars = new char[len];
data.getChars(0, len, chars, 0);
int olen = 3 * (len / 4);
if (chars[len - 2] == '=') {
    --olen;
if (chars[len - 1] == '=') {
    --olen;
byte[] bytes = new byte[olen];
int iidx = 0;
int oidx = 0;
while (iidx < len) {
    int c0 = base64Values[chars[iidx++] & 0xff];
    int c1 = base64Values[chars[iidx++] & 0xff];
    int c2 = base64Values[chars[iidx++] & 0xff];
    int c3 = base64Values[chars[iidx++] & 0xff];
    int c24 = (c0 << 18) | (c1 << 12) | (c2 << 6) | c3;
    bytes[oidx++] = (byte) (c24 >> 16);
    if (oidx == olen) {
        break;
    bytes[oidx++] = (byte) (c24 >> 8);
    if (oidx == olen) {
        break;
    bytes[oidx++] = (byte) c24;
return bytes;
Stringdecodes(String base64)
decodes
return new String(decode(base64));
StringdecodeBase64(String encodedString)
decode Base
byte[] byteData = Base64.decode(encodedString, Base64.NO_WRAP);
String decodedString = null;
try {
    decodedString = new String(byteData, "UTF-8");
} catch (UnsupportedEncodingException e) {
    e.printStackTrace();
return decodedString;
...