java 读取txt时中文乱码
先上代码:public class TestChinese {public static void main(String[] args) throws IOException{test3();}public static void test3() throws IOException{InputStreamReader in=new InputStreamReader(new FileInputStream("e:/a.txt"),"utf-8");BufferedReader br=new BufferedReader(in);String s=null;while((s=br.readLine())!=null){System.out.println(s);}}}
但是输出的中文还是乱码。
eclipse里边修改TestChinese.java文件的编码为utf-8,
再执行就没有乱码了http://www.agoit.com/images/smiles/icon_biggrin.gif
页:
[1]