[IO]——编码和解码
来源:互联网 发布:淘宝 新店扶持 编辑:程序博客网 时间:2024/06/06 01:05
public class Conver {public static void main(String[] args) {String str="中国";byte[] date=str.getBytes();//字节数不完整System.out.println(new String(date,0,3));}/** * 编码和解码字符集必须相同,否则乱码 * @throws UnsupportedEncodingException */public static void test() throws UnsupportedEncodingException {//解码byte-->charString str="中国";//gbk//编码char-->bytebyte[] date=str.getBytes();//编码和解码字符集统一System.out.println(new String(date));date=str.getBytes("utf-8");//设定编码字符集//不同一出现乱码System.out.println(new String(date));/////////////////编码byte[] date2="中国".getBytes("utf-8");//解码str=new String(date2, "utf-8");System.out.println(str);}}
0 0
- [IO]——编码和解码
- Request,Response编码解码原理,文件上传下载和底层IO
- IO流_String类中的编码和解码问题
- Java之IO(六)编码和解码
- Java学习笔记之IO(十六):编码和解码
- IO流编码与解码
- zXing的编码和解码——二维码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Objective-C学习——中文URL编码和解码
- Java常用工具类封装——Base64 编码和解码
- Java中定时任务的实现:Timer与ScheduledExecutorService的不同
- POJ 3687 拓扑排序
- 1. Two Sum
- nginx https 跳转方法
- mysql基本操作
- [IO]——编码和解码
- 线程池中CompletionService的应用
- 字符串转成整数大数乘法
- 说说JSON和JSONP,也许你会豁然开朗
- 关于string函数族实现的准备
- 计算几何----判断点是否在一个矩形内
- [你必须知道的.NET]第三十五回,判断dll是debug还是release,这是个问题
- [IO]——指定字符集
- C++实验3-本月有几天?