runliuv

runliuv@cnblogs

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

 

使用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));
    }

-

 

posted on 2019-03-02 13:37  runliuv  阅读(155)  评论(0编辑  收藏  举报