[英]Java Base64 and Android base64
I'm trying to access a Java WebService, 我正在尝试访问Java WebService,
I'm using Android Base64(Base64.encodeToString(byte[], Base64.DEFAULT))
encode byte array. 我正在使用Android
Base64(Base64.encodeToString(byte[], Base64.DEFAULT))
编码字节数组。 but the Java WebService can't resolve it. 但是Java WebService无法解决它。
I get the following error: 我收到以下错误:
11-30 20:41:39.008: I/System.out(25297): error in opening zip file
JDK Base64Encoder and Android Base64 has different? JDK Base64Encoder和Android Base64有何不同?
Nothing in the android.*
namespace is available in standard Java. android.*
名称空间中的所有内容在标准Java中均不可用。 Use the Base64Encoder
instead. 请改用
Base64Encoder
。 If you are having compatibility problems, you might use a standalone codec like Apache Commons Codec . 如果您遇到兼容性问题,则可以使用独立的编解码器,例如Apache Commons Codec 。
in the webservice, try using javax.xml.bind.DatatypeConverter. 在Web服务中,尝试使用javax.xml.bind.DatatypeConverter。 It has static methods that make this easy.
它具有静态方法,可简化此过程。
for decode : 用于解码:
DatatypeConverter.parseBase64Binary()
and for encode : 和编码:
DatatypeConverter.printBase64Binary()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.