Java 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

byte[]decodeBase64(char[] data)
decode Base
ByteArrayOutputStream baos = new ByteArrayOutputStream(data.length);
int pos = 0, val = 0;
for (int i = 0; i < data.length; i++) {
    val = (val << 6) | decodes[data[i]];
    pos += 6;
    while (pos > 7) {
        baos.write(val >> (pos -= 8));
        val &= ((1 << pos) - 1);
...
intdecodeBASE64(InputStream in, OutputStream out)
This implements a BASE64 character decoder as specified in RFC1521.
int written = 0;
byte[] chunk = new byte[4];
while (base64ReadChunk(in, chunk)) {
    byte a = -1, b = -1, c = -1, d = -1;
    int rem = ((chunk[3] == '=') ? ((chunk[2] == '=') ? 2 : 3) : 4);
    try {
        switch (rem) {
        case 4:
...
intdecodeBase64(InputStream is, OutputStream os)
decode Base
int written = 0;
byte[] buffer = { '=', '=', '=', '=' };
int bufferIndex = 0;
byte[] tmpBuffer = { 0, 0, 0, 0 };
int r, i, outWrite, value;
byte[] outBuffer = { 0, 0, 0 };
while (is.available() > 0) {
    r = is.read(tmpBuffer);
...
byte[]decodeBase64(String base64Data)
decode Base
try {
    return new BASE64Decoder().decodeBuffer(base64Pad(base64Data));
} catch (IOException e) {
    throw new RuntimeException(e);
StringdecodeBase64(String data)
Decodes a base64 String.
byte[] bytes = null;
try {
    bytes = data.getBytes("ISO-8859-1");
} catch (UnsupportedEncodingException uee) {
return decodeBase64(bytes);
StringdecodeBase64(String data)
Decodes a base64 String.
return decodeBase64(data.getBytes("GBK"));
byte[]decodeBASE64(String pEncoded)
decode BASE
BASE64Decoder b64 = new BASE64Decoder();
try {
    return b64.decodeBuffer(pEncoded);
} catch (IOException e) {
    return null;
StringdecodeBase64(String str)
decode Base
if ("".equals(str) && null == str) {
    return null;
} else {
    try {
        byte[] b = new sun.misc.BASE64Decoder().decodeBuffer(str);
        return new String(b);
    } catch (IOException e) {
        e.printStackTrace();
...
StringdecodeBase64AsUtf8(String data)
decode Base As Utf
return encodeAsUtf8(decodeAsBase64(data));
StringdecodeBase64Mime(String encoded)
decode Base Mime
byte[] decoded_bytes = Base64.getMimeDecoder().decode(encoded);
return new String(decoded_bytes, "UTF-8");