字符编码

字符编码

UTF:包含了以下的编码

GBK/GBK2312:表示中文,GBK表示简体和繁体中文,GBK2312只表示简体中文

ISO 8859-1:是全部的英文编码


public class EncodeDemo {
 
 public static void main(String args[])
 {
  System.getProperties().list(System.out);
 }

}

在操作的时候默认编码是GBK编码。

import java.io.*;


public class EncodeDemo {
 
 public static void main(String args[]) throws IOException
 {
  //System.getProperties().list(System.out);
     OutputStream output=new FileOutputStream(new File("d:"+File.separator+"test.txt"));
     String str="中国";
     output.write(str.getBytes("ISO8859-1"));
 }

}

原文地址:https://www.cnblogs.com/jinzhengquan/p/1948424.html