1. 参考表

2.demo:
package cn.com.infosec.netcert.caAdmin.test;
import java.text.ParseException;
import java.util.Base64;
/**
* @Author jy
* @Time 2019-07-15 20:06
*/
public abstract class Test_Base64 {
public static void main(String[] args) throws ParseException {
byte[] b1 = Base64.getEncoder().encode(new byte[]{'a','a','a'});
String str_1 = new String(b1);
System.out.println(str_1); //编码之后 : FWFh
byte[] b2 = Base64.getDecoder().decode(b1);
byte[] b3 = Base64.getDecoder().decode(str_1);
System.out.println(new String(b2)); //解码之后: aaa
System.out.println(new String(b3)); //解码之后: aaa
}
}
3.byte[] 转换为 Base64 编码格式 过程详解:

4. 总结
本文详细介绍了在Java中使用Base64进行字节数组编码和解码的过程,通过具体示例展示了如何将字节数组转换为Base64编码字符串,以及如何从Base64编码字符串还原原始字节数组。
663

被折叠的 条评论
为什么被折叠?



