赞
踩
/** * 基本型:输出被映射到一组字符A-Za-z0-9+/,编码不添加任何行标 * public static Encoder getEncoder()编码器 * public static Decoder getDecoder()解码器 * URL型:输出映射到一组支付A-Za-z0-9+_,输出的是URL和文件 * public static Encoder getUrlEncoder() * public static Decoder getUrlDecoder() * MIME型:输出映射到MIME友好格式,每行输出不超过76个字符,并使用\r并跟随\n * public static Encoder getMimeEncoder() * public static Decoder getMimeDecoder() */
使用案例
- public class Test {
- /**
- * 基本型:输出被映射到一组字符A-Za-z0-9+/,编码不添加任何行标
- * public static Encoder getEncoder()编码器
- * public static Decoder getDecoder()解码器
- * URL型:输出映射到一组支付A-Za-z0-9+_,输出的是URL和文件
- * public static Encoder getUrlEncoder()
- * public static Decoder getUrlDecoder()
- * MIME型:输出映射到MIME友好格式,每行输出不超过76个字符,并使用\r并跟随\n
- * public static Encoder getMimeEncoder()
- * public static Decoder getMimeDecoder()
- */
- public static void main(String[] args) {
- Base64.Encoder encoder = Base64.getEncoder();
- byte[] encode = encoder.encode("嘻嘻哈哈哈".getBytes());
- System.out.println(new String(encode));
- //解码
- Base64.Decoder decoder = Base64.getDecoder();
- byte[] decode = decoder.decode(encode);
- System.out.println(new String(decode));
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。