Here you can find the source of base64Decoder(char[] src, int start)
public final static byte[] base64Decoder(char[] src, int start) throws IOException
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.IOException; public class Main { final static String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; final static char pad = '='; public final static byte[] base64Decoder(char[] src, int start) throws IOException { if (src == null || src.length == 0) return null; char[] four = new char[4]; int i = 0, l, aux; char c;//w w w. ja v a 2s . c o m boolean padded; ByteArrayOutputStream dst = new ByteArrayOutputStream(src.length >> 1); while (start < src.length) { i = 0; do { if (start >= src.length) { if (i > 0) throw new IOException("bad BASE 64 In->"); else return dst.toByteArray(); } c = src[start++]; if (chars.indexOf(c) != -1 || c == pad) four[i++] = c; else if (c != '\r' && c != '\n') throw new IOException("bad BASE 64 In->"); } while (i < 4); padded = false; for (i = 0; i < 4; i++) { if (four[i] != pad && padded) throw new IOException("bad BASE 64 In->"); else if (!padded && four[i] == pad) padded = true; } if (four[3] == pad) { if (start < src.length) throw new IOException("bad BASE 64 In->"); l = four[2] == pad ? 1 : 2; } else l = 3; for (i = 0, aux = 0; i < 4; i++) if (four[i] != pad) aux |= chars.indexOf(four[i]) << (6 * (3 - i)); for (i = 0; i < l; i++) dst.write((aux >>> (8 * (2 - i))) & 0xFF); } dst.flush(); byte[] result = dst.toByteArray(); dst.close(); dst = null; return result; } }