bson/src/main/org/bson/internal/Base64.java
public static byte[] decode(final String s) {
        int delta = s.endsWith("==") ? 2 : s.endsWith("=") ? 1 : 0;
        byte[] buffer = new byte[s.length() * BYTES_PER_UNENCODED_BLOCK / BYTES_PER_ENCODED_BLOCK - delta];
        int mask = 0xFF;
        int pos = 0;
        for (int i = 0; i < s.length(); i += BYTES_PER_ENCODED_BLOCK) {
            int c0 = DECODE_TABLE[s.charAt(i)];
            int c1 = DECODE_TABLE[s.charAt(i + 1)];
            buffer[pos++] = (byte) (((c0 << 2) | (c1 >> 4)) & mask);
            if (pos >= buffer.length) {
                return buffer;
            }
            int c2 = DECODE_TABLE[s.charAt(i + 2)];
            buffer[pos++] = (byte) (((c1 << 4) | (c2 >> 2)) & mask);
            if (pos >= buffer.length) {
                return buffer;
            }
            int c3 = DECODE_TABLE[s.charAt(i + 3)];
            buffer[pos++] = (byte) (((c2 << 6) | c3) & mask);
        }
        return buffer;
    }
public static byte[] decode(final String s) {
        int delta = s.endsWith("==") ? 2 : s.endsWith("=") ? 1 : 0;
        byte[] buffer = new byte[s.length() * BYTES_PER_UNENCODED_BLOCK / BYTES_PER_ENCODED_BLOCK - delta];
        int mask = 0xFF;
        int pos = 0;
        for (int i = 0; i < s.length(); i += BYTES_PER_ENCODED_BLOCK) {
            int c0 = DECODE_TABLE[s.charAt(i)];
            int c1 = DECODE_TABLE[s.charAt(i + 1)];
            buffer[pos++] = (byte) (((c0 << 2) | (c1 >> 4)) & mask);
            if (pos >= buffer.length) {
                return buffer;
            }
            int c2 = DECODE_TABLE[s.charAt(i + 2)];
            buffer[pos++] = (byte) (((c1 << 4) | (c2 >> 2)) & mask);
            if (pos >= buffer.length) {
                return buffer;
            }
            int c3 = DECODE_TABLE[s.charAt(i + 3)];
            buffer[pos++] = (byte) (((c2 << 6) | c3) & mask);
        }
        return buffer;
    }
public static byte [ ] decode ( final String s ) { int delta = s . endsWith ( "==" ) ? 2 : s . endsWith ( "=" ) ? 1 : 0 ; byte [ ] buffer = new byte [ s . length ( ) * BYTES_PER_UNENCODED_BLOCK / BYTES_PER_ENCODED_BLOCK - delta ] ; int mask = 0xFF ; int pos = 0 ; for ( int i = 0 ; i < s . length ( ) ; i += BYTES_PER_ENCODED_BLOCK ) { int c0 = DECODE_TABLE [ s . charAt ( i ) ] ; int c1 = DECODE_TABLE [ s . charAt ( i + 1 ) ] ; buffer [ pos ++ ] = ( byte ) ( ( ( c0 << 2 ) | ( c1 >> 4 ) ) & mask ) ; if ( pos >= buffer . length ) { return buffer ; } int c2 = DECODE_TABLE [ s . charAt ( i + 2 ) ] ; buffer [ pos ++ ] = ( byte ) ( ( ( c1 << 4 ) | ( c2 >> 2 ) ) & mask ) ; if ( pos >= buffer . length ) { return buffer ; } int c3 = DECODE_TABLE [ s . charAt ( i + 3 ) ] ; buffer [ pos ++ ] = ( byte ) ( ( ( c2 << 6 ) | c3 ) & mask ) ; } return buffer ; }
Decodes the given Base64-encoded string.

@param s the Base64-encoded string
@return the decoded byte array
Decodes the given Base64 - encoded string .