1
我必須從txt文件中檢索一些數據,然後在我的應用程序中顯示這些數據。特殊字符Android(ø)
我的問題是,如果我在我的txt裏面有特殊字符'ø',這個不會顯示出來,'?'被顯示。
我會嘗試檢查數據,如
if(string.charAt(i) == 'ø') do sth
或
string.replace('ø' , 'O')
但他們都不是工作,我認爲Java不能識別字符都沒有。
你有什麼想法嗎?
感謝
編輯
這是我讀出的數據
String[] obj = getText(getActivity(), myTXT.txt").split("\n");
其中的getText是:
public String getText(Context c, String fileName){
ByteArrayOutputStream outputStream = null;
try {
AssetManager am = c.getAssets();
InputStream is = am.open(fileName);
outputStream = new ByteArrayOutputStream();
byte buf[] = new byte[1024];
int len;
while ((len = is.read(buf)) != -1){
outputStream.write(buf,0,len);
}
outputStream.close();
is.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return outputStream.toString();
}
請顯示您用來從文件中讀取的代碼。 –