tonglin0325的个人主页

字符编码

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import org.omg.CORBA.portable.OutputStream;

public class code_demo {

public static void main(String[] args) throws Exception {
// TODO 自动生成的方法存根
System.out.println("系统默认编码:"+System.getProperty("file.encoding")); //获取系统当前的编码
File file = new File("/home/common/software/coding/HelloWord/HelloWord/b.txt");//路径
FileOutputStream out = new FileOutputStream(file);
byte b[] = "中国".getBytes("ISO8859-1");
out.write(b);
out.close();
}

}