package com.sheting.basic.utilities;
import java.util.Base64;
public class HelloBase64 {
public static void main(String[] args) {
String msg = "Hello, Base64!";
Base64.Encoder enc = Base64.getEncoder();
byte[] encbytes = enc.encode(msg.getBytes());
System.out.println(new String(encbytes));
Base64.Decoder dec = Base64.getDecoder();
byte[] decbytes = dec.decode(encbytes);
System.out.println(new String(decbytes));
}
}
output
SGVsbG8sIEJhc2U2NCE=
Hello, Base64!
details: https://www.javaworld.com/article/3240006/java-language/base64-encoding-and-decoding-in-java-8.html
最后
以上就是坚强板栗最近收集整理的关于Base64 encoding and decoding in Java 8的全部内容,更多相关Base64内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复