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
蒋家狂潮 阅读(193)
评论(0) 编辑 收藏 所属分类:
Basic