我在手机的特定文件夹中阅读了一个txt文档;这是阅读文档的代码:
public String read_file(String curFileName, String curFilePath) {
File file = new File(curFilePath,curFileName);
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8")));
String line;
while ((line = br.readLine()) != null) {
text.append(line+"\n");
}
br.close();
}
catch (IOException e) {
//
}
TextView tv = (TextView)findViewById(R.id.dir);
tv.setMovementMethod(new ScrollingMovementMethod());
tv.setText(text);
return text.toString();
}
但是在textView中,诸如“和其他”之类的特殊字符无法识别。这是图像: