開發過程中遇到這個問題,雖然不影響項目運行,打包發佈,但還是要把警告扼殺在搖籃中。
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));
}
}