欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

JAVA Base64,

来源: javaer 分享于  点击 37607 次 点评:148

JAVA Base64,




import java.io.IOException;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class Base64 {


/**
*
* @param s
* @return<br>
* @date 2013年8月23日下午10:36:45<br>
*
*/
public static String encode(String s) {
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(s.getBytes());
}

public static String decode(String s) {
BASE64Decoder decoder = new BASE64Decoder();
try {
return new String(decoder.decodeBuffer(s));
} catch (IOException e) {
e.printStackTrace();
}
return null;
}

public static String decode(String s, String codeType) {
BASE64Decoder decoder = new BASE64Decoder();
try {
return new String(decoder.decodeBuffer(s), codeType);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}

相关文章

    暂无相关文章
相关栏目:

用户点评