![](/img/trans.png)
[英]Need to read from a txt file in the assets folder in android studio
[英]'The file name must end with .xml' when i try to read the value from text file(.txt) inside the assets folder
我正在嘗試從assets
文件夾內的文本文件(.txt)中讀取值,當我嘗試重建項目時,出現此錯誤,如何解決?
The file name must end with .xml
這是java代碼,我正在嘗試從文本文件中讀取值,
try {
InputStream is=getAssets().open("english.text");
int size=is.available();
byte[] buffer=new byte[size];
is.read(buffer);
is.close();
line=new String(buffer);
} catch (IOException e) {
e.printStackTrace();
}
您將
assets\/<\/code>目錄放在錯誤的位置。
它需要直接在
main\/<\/code>下,作為
java\/<\/code>和
res\/<\/code>的對等點。
"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.