Here you can find the source of base64decode(String str)
public static String base64decode(String str)
//package com.java2s; //License from project: Open Source License import java.io.UnsupportedEncodingException; public class Main { static byte[] revBase64; public static String base64decode(String str) { int len = str.length(); if ((len & 3) != 0) throw new IllegalArgumentException("Not Base64: " + str); int padstart = str.indexOf('=', len - 3); int padding = padstart == -1 ? 0 : len - padstart; byte[] utf8 = new byte[len / 4 * 3]; for (int i = 0; i < len / 4; i++) { int value = (revBase64[str.charAt(4 * i)] << 18) + (revBase64[str.charAt(4 * i + 1)] << 12) + (revBase64[str.charAt(4 * i + 2)] << 6) + revBase64[str.charAt(4 * i + 3)]; utf8[3 * i + 0] = (byte) (value >> 16); utf8[3 * i + 1] = (byte) (value >> 8); utf8[3 * i + 2] = (byte) (value); }/*from w ww . ja v a 2s .co m*/ try { return new String(utf8, 0, utf8.length - padding, "UTF-8"); } catch (UnsupportedEncodingException ex) { throw new InternalError(ex.toString()); } } }