java读写中文无乱码的方法

2014-05-15 14:57 来源:www.chinab4c.com 作者:ecshop专家

             java读写中文无乱码的方法

             File f = new File("f.txt");
             FileOutputStream fos = new FileOutputStream(f,true);
             BufferedOutputStream bof = new BufferedOutputStream(fos);
             String xxx = "日eee";
             byte b[] = xxx.getBytes();
             bof.write(b);
             bof.flush();
             File ff = new File("f.txt");
             FileInputStream fis = new FileInputStream(ff);
             InputStreamReader isr = new InputStreamReader(fis,"utf-8");
             BufferedReader br = new BufferedReader(isr);
             System.out.println(br.readLine());

           来源:http://www.chinab4c.com