- Java code
FileReader fr = new FileReader(f); //System.out.print(fr.getEncoding()); BufferedReader br = new BufferedReader(fr); String str = br.readLine(); while(str!= null) { ta.append(str); ta.append("\n"); str = br.readLine(); } ta.append("中"); fr.close(); br.close();
ta是textarea,f是一个txt文件,问题是可以显示“中”,但是从f中读取的中文字不能正确显示,怎么回事?
------解决方案--------------------
- Java code
FileInputStream fr = new FileInputStream(f); InputStreamReader br = new InputStreamReader(fr, "GB2312");