Java base64 编码、解码
作者:互联网
public class uploadServletTest {
@Test
public void name() throws IOException {
String content = "这里是Base64编码的内容";
//编码
BASE64Encoder base64Encoder = new BASE64Encoder();
String encodeStr = base64Encoder.encode(content.getBytes("utf-8"));
System.out.println(encodeStr);
//解码
BASE64Decoder base64Decoder = new BASE64Decoder();
byte[] bytes = base64Decoder.decodeBuffer(encodeStr);
String s = new String(bytes, "utf-8");
System.out.println(s);
}
}
标签:编码,base64Encoder,Java,String,解码,base64,base64Decoder,encodeStr,new 来源: https://www.cnblogs.com/kutsu/p/14678261.html