- 将二进制数组转字符串
String str = new String(bytes,StandardCharsets.UTF_8);
- 将字符串转二进制数组
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
- 将base64加密的字符串解密并输出
Base64Utils工具类来自于org.springframework.util.Base64Utils
public String decode(String str){
byte[] bytes = Base64Utils.decodeFromString(str);
return new String(bytes,StandardCharsets.UTF_8);
}