dter8514 2014-12-09 15:42
浏览 1838

java.lang.IllegalArgumentException:android中的bad base-64

I am developing a application where i keep records of user in form of profile.

Where i takes the image as input and then converts it into the base64 string using android's built-in conversion functionality.

byte[] b = baos.toByteArray();
final String imageText = Base64.encodeToString(b,Base64.URL_SAFE|Base64.No_WRAP);

and send it to server using PHP Code and save that to MySQL DB

MySQL Server

Engine is "MyISAM"

column type "text"

column collation "utf8_general_ci"

Then Retrieves using PHP in the form of XML.

In Android I am parsing the XML and Decoding the Encoded string.

like this

byte[] decodedByte = Base64.decode(String,Base64.URL_SAFE|Base64.No_WRAP); b = BitmapFactory.decodeByteArray(decodedByte,0,decodedByte.length);

But Sometimes it works perfect but sometimes i get

java.lang.IllegalArgumentException: bad base-64
at android.util.Base64.decode(Base64.java:161)
at android.util.Base64.decode(Base64.java:136)
at android.util.Base64.decode(Base64.java:118)
at... 

Please help me i am new to android.

Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突