开发过程中遇到这个问题,虽然不影响项目运行,打包发布,但还是要把警告扼杀在摇篮中。
sun.misc包都是sun公司的内部类,并没有在java api中公开过,不建议使用,所以使用这些方法是不安全的,将来随时可能会从中去除,所以相应的应该使用替代的对象及方法。
针对警告: BASE64Decoder是内部专用 API, 可能会在未来发行版中删除
解决办法
采用org.apache.commons.codec.binary.Base64替换
import org.apache.commons.codec.binary.Base64;
/**
* @author cool
* @version V1.0
* @className Base64Encoder
* @description Problem In Chair, Not In Computer.
* @createDate 2018年07月09日
*/
public class Base64Encoder {
/**
* @param bytes
* @return
*/
public static byte[] decode(final byte[] bytes) {
return Base64.decodeBase64(bytes);
}
/**
* 二进制数据编码为BASE64字符串
*
* @param bytes
* @return
* @throws Exception
*/
public static String encode(final byte[] bytes) {
return new String(Base64.encodeBase64(bytes));
}
}