随笔-50  评论-55  文章-8  trackbacks-0

JAVA的BASE64编码与解码:
1、编码:
publicstaticString getBASE64(String s) {
if (s == null) returnnull;
return (new sun.misc.BASE64Encoder()).encode( s.getBytes() );
}
2、解码:
publicstaticString getFromBASE64(String s) {
if (s == null) returnnull;
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] b = decoder.decodeBuffer(s);
returnnewString(b);
} catch (Exception e) {
returnnull;
}
}

posted on 2009-01-06 10:12 蒋家狂潮 阅读(183) 评论(0)  编辑  收藏 所属分类: Basic

只有注册用户登录后才能发表评论。


网站导航: