Java 9版本之后Base64Encoder和Base64Decoder无法继续使用解决办法

Wesley13
• 阅读 595

在项目开发过程中,因为重装系统,安装了Java10版本,发现sun.misc.Base64Encoder和sun.misc.Base64Decoder无法使用。


原因:

查看官网发现,JDK中的/lib/tool.jar和/lib/rt.jar已经从Java SE 9中删除,(我估计是因为java从sun换到oracle导致)。


处理办法:

直接用 java.util.Base64.Encoder 和 java.util.Base64.Decoder 替代使用。可以直接使用以下方法:

  1. import java.util.Base64.Encoder
  2. import java.util.Base64.Decoder
  3. Encoder encoder = Base64.getEncoder();
  4. String result = encoder.encodeToString(byteArray);
  5. Decoder decoder = Base64.getDecoder();
  6. byte\[\] result = decoder.decode(str);

原文地址:https://blog.csdn.net/xie\_sining/article/details/80777164
点赞
收藏
评论区
推荐文章
Easter79 Easter79
2年前
sql:mysql:函数:TIMESTAMPDIFF函数实现TimeStamp字段相减,求得时间差
<divclass"htmledit\_views"id"content\_views"<p&nbsp;函数内指定是minute,则最终结果value值的单位是分钟,如果函数内指定为hours,则最终结果value值单位为小时。</p<preclass"has"name"code"<codeclass"hljssql"<
Wesley13 Wesley13
2年前
Java面试
<divclass"htmledit\_views"id"content\_views"<pid"maintoc"<strong目录</strong</p<pid"Java%E5%9F%BA%E7%A1%80%EF%BC%9Atoc"style"marginleft:40px;"<ahref"Java%E5%
Wesley13 Wesley13
2年前
Java中Class对象详解
<divclass"htmledit\_views"id"content\_views"<phttps://blog.csdn.net/mcryeasy/article/details/52344729<br</p<p待优化整理总结</p<p</p<h1style"padding:0px;fontfamily:'apple
Stella981 Stella981
2年前
LocalDateTime计算时间差
<divclass"htmledit\_views"id"content\_views"<pLocalDateTime为java8的新特性之一<br</p<p<br</p<pLocalDateTime.now()获得当前时间<br</p<p</p<h5</h5<divstyle"marginleft
Wesley13 Wesley13
2年前
Activiti 工作流入门指南
<divclass"htmledit\_views"id"content\_views"<h1<aname"t0"</a概览</h1<p如我们的介绍部分所述,Activiti目前分为两大类:</p<ul<li<p<ahref"https://activiti.gitbook.io/activiti7deve
Stella981 Stella981
2年前
Linux下CPU占用率高分析方法
<divclass"htmledit\_views"id"content\_views"<p一、可能有线程一直占用CPU资源</p<p1.先通过ps查看进程状态,找出进程的PID(8209)。</p<p2.jstackl8209&gt;/usr/local/work/tomcat/8209.stack导出PID
Stella981 Stella981
2年前
Python基础教程,Python入门教程(非常详细)
<divclass"htmledit\_views"id"content\_views"<p<ahref"http://c.biancheng.net/python/base/"rel"nofollow"第1章Python编程基础</a</p<p1.<ahref"http://c.biancheng.net/view/
Stella981 Stella981
2年前
CodeBlocks下载与安装教程
<divclass"htmledit\_views"id"content\_views"<p一、下载教程</p<p1.在浏览器上搜索CodeBlocks官网或者直接输入网址<ahref"http://www.codeblocks.org/"rel"nofollow"http://www.codeblocks.org/进入Co
Stella981 Stella981
2年前
Neo4j 的一些使用心得
<divclass"htmledit\_views"id"content\_views"<p<br</p<p<spanstyle"color:rgb(70,70,70);fontfamily:simsun;fontsize:14px;lineheight:21px;"由对图数据的处理需求,看到了图数据库(GraphData
Stella981 Stella981
2年前
Neo4j删除节点和关系、彻底删除节点标签名
<divclass"htmledit\_views"id"content\_views"<p<ahref"https://www.jianshu.com/p/59bd829de0de"rel"nofollow"datatoken"720f42e8792665773f66044d30a60222"https://www.jians