解码和编码
来源:互联网 发布:童鞋淘宝网 编辑:程序博客网 时间:2024/06/05 20:16
import java.io.IOException;
import org.junit.Test;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
* 解码和编码
* @version 2016-8-31下午9:01:29
**/
public class TestBase64Encoder {
/**
* 编码
* @param str //要编码的字符串
* @param codeFormat //编码格式
* @throws IOException
*/
@Test
public String encoding(String str, String codeFormat) throws IOException {
BASE64Encoder base64encoder = new BASE64Encoder();
String encode = base64encoder.encode(str.getBytes(codeFormat));
return encode;
}
/**
* 解码
* @param str //要解码的字符串
* @param codeFormat //解码的格式
* @throws IOException
*/
public String decoding(String str, String codeFormat) throws IOException {
//解码
BASE64Decoder decoder = new BASE64Decoder();
byte[] decode = decoder.decodeBuffer(str);
String deco = new String(decode, codeFormat);
return deco;
}
}
import org.junit.Test;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
* 解码和编码
* @version 2016-8-31下午9:01:29
**/
public class TestBase64Encoder {
/**
* 编码
* @param str //要编码的字符串
* @param codeFormat //编码格式
* @throws IOException
*/
@Test
public String encoding(String str, String codeFormat) throws IOException {
BASE64Encoder base64encoder = new BASE64Encoder();
String encode = base64encoder.encode(str.getBytes(codeFormat));
return encode;
}
/**
* 解码
* @param str //要解码的字符串
* @param codeFormat //解码的格式
* @throws IOException
*/
public String decoding(String str, String codeFormat) throws IOException {
//解码
BASE64Decoder decoder = new BASE64Decoder();
byte[] decode = decoder.decodeBuffer(str);
String deco = new String(decode, codeFormat);
return deco;
}
}
0 0
- base64编码和解码
- uuencode编码和解码
- BASE64编码和解码
- base64编码和解码
- base64编码和解码
- BASE64 编码和解码
- URL编码和解码
- NIO编码和解码
- 编码和解码问题
- Base64编码和解码
- 曼切斯特差分编码和解码
- BASE64编码和解码
- JavaScript编码 和 解码
- 编码和解码
- url编码和解码
- base64编码和解码
- url编码和解码
- URL编码和解码
- SpringMVC拦截器
- 常用的数据结构操作flash模拟演示
- JAVA文件下载(2)
- 出差这件小事
- 用JS设置CSS属性,并取消属性
- 解码和编码
- 普元eos6.5 初始化mysql 数据库,异常处理一:
- 51nod-1110 距离之和最小 V3(中位数)
- python ctypes
- 事务457——事务的七个传播行为
- 抽奖-高并发
- java-jsp
- Scala 初级入门课程一
- 【算法之美-经典问题】九宫格问题