我有一个包含许多中文字符的txt文件,而txt文件位于res/raw/test.txt目录中。我想阅读文件,但不知何故,我不能让中文字符正确显示。这里是我的代码:Android:如何读取包含中文字符的txt文件?
try {
InputStream inputstream = getResources().openRawResource(R.raw.test);
BufferedReader bReader = new BufferedReader(
new InputStreamReader(inputstream,Charset.forName("UTF-8")));
String line = null;
while ((line= bReader.readLine())!= null) {
Log.i("lolo", line);
System.out.println("here is some chinese character 这是一些中文字");
}
} catch (IOException e) {
e.printStackTrace();
}
Log.i(“lolo”,line);和System.out.println(“这里是一些中文字符这是一些中文字”)不能正确显示字符,我甚至不能在println()方法中看到中文字符。 我能做些什么来解决这个问题?有谁能够帮助我?
谢谢,我可以用你的答案解决这个问题 – TianDong 2010-06-06 12:43:01