请问在 JDK 中用哪个类对 String 进行 Base64编码? 试试 java.net.URLDecoder.decode("your String"); 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可参加jarkatar-commons项目的codec子项目 目前 Jakarta Commons Codec已经提供 base64, hex, 及 metaphone, soundex 等编码. 下载位置为: http://jakarta.apache.org/commons/codec/index.html Base64 编解码 base64 编解码技术广泛地利用在 Internet 之上, 主要就是将 bytecode 转换成 ascii 码, 最常常使用的则是属于电子邮件附件的传输. 你可以查看你的邮件原码, 如果有 Content-Transfer-Encoding: base64 , 就代表这封信有采用 base64 来编码, 另外则是 QP ( quoted-printable ) 编码方式, 基本上大多数的读信软件都有支持. package com.softleader.sample.codec;import org.apache.commons.codec.binary.Base64;import org.apache.commons.codec.*;public class Base64Test { public static void main(String args[]) { Base64 base64 = new Base64(); String str = "中文"; byte[] enbytes = null; String encodeStr = null; byte[] debytes = null; String decodeStr = null; try { enbytes = base64.encode(str.getBytes()); encodeStr = new String(enbytes); debytes = base64.decode(enbytes); decodeStr = new String(debytes); } catch (EncoderException ex) { System.out.println("编码错误"); } catch (DecoderException ex) { System.out.println("解码错误"); } System.out.println("编码前:"+str); System.out.println("编码后:"+encodeStr); System.out.println("解码后:"+decodeStr); }}cmd>java com.softleader.sample.codec.Base64Test执行结果编码前:中文编码后:pKSk5Q==解码后:中文 一个接口的异常处理问题? 一个很郁闷的改错题,我都不知道要考我什么? 折线图的提示信息 帮忙看下 谢谢 感觉自己遇到了瓶颈,希望高手能指点一下 求助各位高手~~ 如何编译相互引用的java文件?? 小问题,马上给分! 新手问题之二:怎样关闭对话框(JDIALOG)?不是通过工具栏上的X按钮! 请问这种情况的程序应该怎样写? 有关华为JAVA工程师面试的问题 现在有三个小小的applet ,给大家实现下,给分的...
http://jakarta.apache.org/commons/codec/index.html
Base64 编解码 base64 编解码技术广泛地利用在 Internet 之上, 主要就是将 bytecode 转换成 ascii 码, 最常常使用的则是属于电子邮件附件的传输. 你可以查看你的邮件原码, 如果有 Content-Transfer-Encoding: base64 , 就代表这封信有采用 base64 来编码, 另外则是 QP ( quoted-printable ) 编码方式, 基本上大多数的读信软件都有支持. package com.softleader.sample.codec;import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.*;public class Base64Test { public static void main(String args[]) {
Base64 base64 = new Base64();
String str = "中文";
byte[] enbytes = null;
String encodeStr = null;
byte[] debytes = null;
String decodeStr = null;
try {
enbytes = base64.encode(str.getBytes());
encodeStr = new String(enbytes);
debytes = base64.decode(enbytes);
decodeStr = new String(debytes);
} catch (EncoderException ex) {
System.out.println("编码错误");
} catch (DecoderException ex) {
System.out.println("解码错误");
}
System.out.println("编码前:"+str);
System.out.println("编码后:"+encodeStr);
System.out.println("解码后:"+decodeStr);
}
}cmd>java com.softleader.sample.codec.Base64Test
执行结果
编码前:中文
编码后:pKSk5Q==
解码后:中文