code: public static byte[] decode(String text) throws Exception
  	{
  		if (text.length() % 4 != 0)
  		{
  			throw new Exception("Base64 not a multiple of 4 bytes");
  		}
  
  		byte[] result = new byte[text.length() / 4 * 3];
  		int p = 0;
  
  		for (int i = 0; i < text.length();)
  		{
  			if (text.charAt(i) == '\n')
  			{
  				continue;
  			}
  
  			int b1 = b64decode(text.charAt(i++));
  			int b2 = b64decode(text.charAt(i++));
  			int b3 = b64decode(text.charAt(i++));
  			int b4 = b64decode(text.charAt(i++));
  
  			if (b4 >= 0)
  			{
  				int three = b4 | b3 << 6 | b2 << 12 | b1 << 18;
  				result[p++] = (byte) ((three & 0xff0000) >> 16);
  				result[p++] = (byte) ((three & 0xff00) >> 8);
  				result[p++] = (byte) (three & 0xff);
  			} else if (b3 >= 0)
  			{
  				int two = b3 << 6 | b2 << 12 | b1 << 18;
  				result[p++] = (byte) ((two & 0xff0000) >> 16);
  				result[p++] = (byte) ((two & 0xff00) >> 8);
  			} else
  			{
  				int one = b2 << 12 | b1 << 18;
  				result[p++] = (byte) ((one & 0xff0000) >> 16);
  			}
  		}
  
  		byte[] output = new byte[p];
  		System.arraycopy(result, 0, output, 0, p);
  
  		return output;
  	}
docs: Base64 decode a string into a byte array.
  
  @param text
  The encoded base64 text.
  @return a byte array of the decoded data.
  @throws Exception