解码 base64 字符串 Java 5
是否有直接使用 Java 1.5 库对 base64 字符串进行解码的直接方法?
Is there a straight forward way to decode a base64 string using ONLY THE JAVA 1.5 LIBRARIES?
由于 Windows 和 Mac OS X 之间的跨平台兼容性问题,我必须使用 Java 1.5(只有 Mac 10.5 支持 Java 1.6,低于 10.5 的所有东西都默认使用 Java 1.5).
I have to use Java 1.5 due to cross platform compatibility issues between Windows and Mac OS X (only Mac 10.5 supports Java 1.6, everything lower than 10.5 has Java 1.5 as default).
对象sun.misc.Base64Decoder"存在于 Java 6 中,但不存在于 Java 5 中.
The object "sun.misc.Base64Decoder" exists in Java 6, but not in Java 5.
推荐答案
不,仅使用JDK 5.0是不可能的.
No, it's not possible based on just using JDK 5.0.
您需要推出自己的实现(这并不难),或者最好使用其中一种开源实现.有很多包括提供 Base64 的 Commons Codec http://commons.apache.org/codec/api-release/org/apache/commons/codec/binary/Base64.html
You'll need to roll your own implementation (it isn't that hard) or preferably use one of the open source implementations. There are lots including Commons Codec which provides Base64 http://commons.apache.org/codec/api-release/org/apache/commons/codec/binary/Base64.html
JavaMail 还通过 MimeUtility 提供 Base64 编码/解码,它还提供引用的可打印编码等...
JavaMail also provides Base64 encoding/decoding via MimeUtility which also does quoted printable encoding etc...
http://java.sun.com/产品/javamail/javadocs/javax/mail/internet/MimeUtility.html
相关文章