赞
踩
- //编码
- String message = "我是码农";
- String encode = Base64.getEncoder().encodeToString(message.getBytes(StandardCharsets.UTF_8)); // 方式一
- String encode2 = new String(Base64.getEncoder().encode(message.getBytes()), StandardCharsets.UTF_8); // 方式二
- System.out.println(encode); // 5oiR5piv56CB5Yac
- System.out.println(encode2); // 5oiR5piv56CB5Yac
- //解码
- String decode = new String(Base64.getDecoder().decode(encode), StandardCharsets.UTF_8);
- System.out.println(decode); // 我是码农
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。