java读文件和写文件编码方式的控制

在java中常常遇到文件读写的问题,有时候需呀控制读写文件的编码格式

方法如下:

读文件

FileInputStream fr = new FileInputStream(path); 
InputStreamReader is = new InputStreamReader(fr,"UTF-8"); 
BufferedReader br=new BufferedReader(is);

写文件

FileOutputStream stream;// provides file access 
OutputStreamWriter writer;// writes to the file  
  
     stream = new FileOutputStream(filename); 
    writer = new OutputStreamWriter(stream,"UTF-8");  

posted on 2013-12-25 15:10  hawen  阅读(284)  评论(0编辑  收藏  举报

导航