代码
//base64编码 String a = new String(base64.encode(text.getBytes("UTF-8"))); String b = new String(Base64.encodeBase64(text.getBytes("UTF-8"))); String c = new BASE64Encoder().encode(text.getBytes("UTF-8")); //base64解码 String aa = new String(base64.decode(a)); String bb = new String(Base64.decodeBase64(b)); String cc = new String(new BASE64Decoder().decodeBuffer(c)); System.out.println("a=" + a); System.out.println("b=" + b); System.out.println("c=" + c); System.out.println("aa=" + aa); System.out.println("bb=" + bb); System.out.println("cc=" + cc);
结果