使用commons-codec,
下载地址
http://commons.apache.org/proper/commons-codec/
下载commons-codec-1.12-bin.zip,解压出来,引用commons-codec-1.12.jar,import org.apache.commons.codec.binary.Base64;
public static byte[] decode(String str) throws Exception { Base64 _base64 = new Base64(); return _base64.decodeBase64(str.getBytes()); }
public static String encode(byte[] bytes) throws Exception { Base64 _base64 = new Base64(); return new String(_base64.encodeBase64Chunked(bytes)); }
-