当前位置: 技术问答>java相关
how to change Unicode to SJIS?
来源: 互联网 发布时间:2015-02-19
本文导语: How to change Unicode to SJIS or GBK2312? I would you can give me a example. | import java.io.*; public class Hello{ public static void main(String[] args)throws IOException{ String str = "照相机"; ...
How to change Unicode to SJIS or GBK2312?
I would you can give me a example.
I would you can give me a example.
|
import java.io.*;
public class Hello{
public static void main(String[] args)throws IOException{
String str = "照相机";
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream("c:\a.txt"),"BIG5");//用BIG5编码
osw.write(str,0,str.length());
osw.close();
osw = new OutputStreamWriter(
new FileOutputStream("c:\b.txt"),"GB2312");//用GB2312编码
osw.write(str,0,str.length());
osw.close();
}
}
public class Hello{
public static void main(String[] args)throws IOException{
String str = "照相机";
OutputStreamWriter osw = new OutputStreamWriter(
new FileOutputStream("c:\a.txt"),"BIG5");//用BIG5编码
osw.write(str,0,str.length());
osw.close();
osw = new OutputStreamWriter(
new FileOutputStream("c:\b.txt"),"GB2312");//用GB2312编码
osw.write(str,0,str.length());
osw.close();
}
}