public class Test {
public static void main(String args[]){
String str = "蔡谦® ² º ¹ ⁹";
try {
String s = new String(Base64.getEncoder().encode(str.getBytes()), "UTF-8");
System.out.println(s);
String ss = new String(Base64.getDecoder().decode(s));
System.out.println(ss);
}catch (UnsupportedEncodingException e){
System.out.println(e.getCause());
}
}
}
/* 输出
6JSh6LCmwq4gwrIgwrogwrkg4oG5
蔡谦® ² º ¹ ⁹ */