0%

字节流中文乱码处理(转换流)

转换流

1
2
3
4
5
6
7
8
9
10
public void LuanMa(){
FileOutputStream fos = new FileOutputStream("X:\\xxx.xxx");
//BufferedOutputStream bos = new BufferedOutputStream(fos);//缓冲流自动处理乱码
OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");//UTF-8,GBK等
//fos.write("hello 中国".getBytes());//产生乱码
osw.write("hello 中国");
//bos.close();
osw.close();
fos.close();
}
------ THEEND ------

欢迎关注我的其它发布渠道