Android: How to read a txt file which contains Chinese characters?
Posted
by TianDong
on Stack Overflow
See other posts from Stack Overflow
or by TianDong
Published on 2010-06-01T16:38:22Z
Indexed on
2010/06/01
16:53 UTC
Read the original article
Hit count: 388
Hallo, i have a txt file which contains many chinese characters, and the txt file is in the directory res/raw/test.txt. I want to read the file but somehow i can't make the chinese characters displayed correctly. Here is my code:
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(); }
Both Log.i("lolo", line); and System.out.println("here is some chinese character ???????") don't show characters correctly, i can not even see the chinese characters in the println() method. What can i do to fix this problem? Can anybody help me?
© Stack Overflow or respective owner