解决办法:
对于只需要Base64编码的简单场景,可以考虑使用Java 8及以上版本提供的内置`java.util.Base64`类,这是一个标准API,无需额外引入任何库:
//import sun.misc.BASE64Encoder; // java8 import java.util.Base64; // java17 public class Base64EncodingExample { public static void main(String[] args) { String textToEncode = "Hello, World!"; String encoded = Base64.getEncoder().encodeToString(textToEncode.getBytes()); System.out.println("Encoded: " + encoded); String decoded = new String(Base64.getDecoder().decode(encoded)); System.out.println("Decoded: " + decoded); } }
参考:https://download.csdn.net/download/qq_36386526/10175811?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ECtr-1-10175811-blog-125922071.235%5Ev43%5Epc_blog_bottom_relevance_base3&depth_1-utm_source=distribute.pc_relevant.none-task-download-2%7Edefault%7ECTRLIST%7ECtr-1-10175811-blog-125922071.235%5Ev43%5Epc_blog_bottom_relevance_base3&utm_relevant_index=2
标签:BASE64Encoder,String,package,jdk17,sun,10175811,Base64,blog,download From: https://www.cnblogs.com/xiluhua/p/18282573