- 代码:
String str="123456";
String encode = new BASE64Encoder().encode(str.getBytes());
System.out.println("编码过后:"+encode);
byte[] bytes = new BASE64Decoder().decodeBuffer(encode);
String decode = new String(bytes, "UTF-8");
System.out.println("解码过后:"+decode);
- 输出结果:
编码过后:MTIzNDU2
解码过后:123456
- 注意解码后的编码格式。。