我正试图在Android中使用http://developer.android.com/reference/android/util/Base64.html类解码一个Base64编码的字符串。
无论是encodeToString还是decode方法都返回null,我不知道出了什么问题,以下是我的解码代码:
// Should decode to "GRC"
String friendlyNameBase64Encoded = "R1JD";
// This returns null
byte[] friendlyNameByteArray = Base64.decode(friendlyNameBase64Encoded, Base64.DEFAULT);
// Fails with NullPointerException
String friendlyName = new String(friendlyNameByteArray, "UTF-8");
我正在运行Android API 23.1.0
android.util.Base64
类,因此返回了null
。也许这个链接能帮到你 http://tools.android.com/tech-docs/unit-testing-support。 - Suhas