Android項目引用不到如下兩個java類java
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
Android有本身的base64類android
import android.util.Base64
//import android.util.Base64; String str = "Hello!"; //base64編碼 //String strBase64 = new String(Base64.encode(str.getBytes(), Base64.DEFAULT)); String strBase64 = Base64.encodeToString(str.getBytes(), Base64.DEFAULT); //base64解碼 String str2 = new String(Base64.decode(strBase64.getBytes(), Base64.DEFAULT));