随笔 - 547  文章 - 1  评论 - 292  阅读 - 33万

警告: BASE64Decoder是内部专用 API, 可能会在未来发行版中删除

警告: BASE64Decoder是内部专用 API, 可能会在未来发行版中删除

复制代码
import org.apache.commons.codec.binary.Base64;

public class Base64Encoder {
    /**
     * @param bytes
     * @return
     */
    public static byte[] decode(final byte[] bytes) {
        return Base64.decodeBase64(bytes);
    }

    /**
     * 二进制数据编码为BASE64字符串
     *
     * @param bytes
     * @return
     * @throws Exception
     */
    public static String encode(final byte[] bytes) {
        return new String(Base64.encodeBase64(bytes));
    }

}


//原来的方式
//            byte[] bytes = new BASE64Decoder().decodeBuffer(base64);
//替换后的方式
            byte[] bytes = Base64Encoder.decode(base64.getBytes());
            
//原来的方式
//            result = Base64.encode(str4);
//替换后的方式
            result = Base64Encoder.encode(str4);
复制代码

 

posted on   oktokeep  阅读(1854)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
· SQL Server 2025 AI相关能力初探
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示