在java中常常遇到文件读写的问题,有时候需呀控制读写文件的编码格式
方法如下:
读文件
FileInputStream fr = new FileInputStream(path);InputStreamReader is = new InputStreamReader(fr,"UTF-8");
BufferedReader br=new BufferedReader(is);
写文件
FileOutputStream stream;// provides file accessOutputStreamWriter writer;// writes to the file
stream = new FileOutputStream(filename);
writer = new OutputStreamWriter(stream,"UTF-8");