我从文件夹中读取了一个文件,并且文件是拉丁文。 当我尝试阅读某些字符?时,如何显示字符。 我尝试了许多对我不起作用的解决方案。 所以任何人都知道这一点。
我到目前为止已经完成了。
void ReadFile() {
File fileDirectory = new File(Environment.getExternalStorageDirectory()
+ "/Offline Lyric/");
// lists all the files into an array
//read file text
File file = new File(fileDirectory, String.valueOf(songnamestring));
//Read text from file
StringBuilder text = new StringBuilder();
try {
//BufferedReader br = new BufferedReader(new FileReader(file));
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
br.close();
} catch (IOException e) {
e.printStackTrace();
}
//Find the view by its id
//Set the text
try {
songlyric.setText("" + new String(text.toString().getBytes("ISO-8859-1"), "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//set type face
caveat = Typeface.createFromAsset(LyricActivity.this.getAssets(), "caveat-regular.ttf");
bellotaltilc = Typeface.createFromAsset(LyricActivity.this.getAssets(), "BellotaItalic.ttf");
songlyric.setTypeface(bellotaltilc);
}
预先感谢