String test = "test字符串"; //方法一 final Base64.Encoder encoder = Base64.getEncoder(); final Base64.Decoder decoder = Base64.getDecoder(); String encodeText = encoder.encodeToString(test.getBytes("UTF-8")); System.out.println(encodeText); String s = new String(decoder.decode(encodeText), "UTF-8"); System.out.println(s) //方法二 encodeText = Base64Utils.encodeToString(s.getBytes("UTF-8")); System.out.println("2:"+encodeText); String s1 = new String(Base64Utils.decode(encodeText.getBytes()),"UTF-8"); System.out.println("s1:"+s1);
原文地址:https://www.cnblogs.com/11HAN/p/12119216.html
时间: 2024-10-11 06:23:01