警告: 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);
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有