海纳百川有容乃大。
@Test
public void de() throws Exception {
final Base64.Decoder decoder = Base64.getDecoder();
final Base64.Encoder encoder = Base64.getEncoder();
final String text = "字串文字";
final byte[] textByte = text.getBytes("UTF-8");
//編碼
final String encodedText = encoder.encodeToString(textByte);
System.out.println(encodedText);
//解碼
System.out.println(new String(decoder.decode(encodedText), "UTF-8"));
}
本文通过一个具体的示例,详细展示了如何使用Java进行Base64编码和解码操作,包括创建编码器和解码器,以及如何将字符串转换为字节数组并进行编码和解码。

2450

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



